Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @interface KOMainViewController() <UITableViewDelegate, UITableViewDataSource, MKAnnotation>
- @property(nonatomic)MKMapView *mapView;
- @end
- @implementation KOMainViewController
- @synthesize KOTableViewWithClients;
- @synthesize shops_array,coordinate,partners_info_array,logos,brand;
- - (void)viewDidLoad {
- [super viewDidLoad];
- shops_array = [NSMutableArray array];
- partners_info_array = [NSMutableArray array];
- logos = [NSMutableArray array];
- brand = [NSMutableArray array];
- [self getPartneFromServer];
- [self getDataFromServer];
- self.mapView.delegate = self;
- KOTableViewWithClients.delegate = self;
- KOTableViewWithClients.dataSource = self;
- }
- - (void) getDataFromServer {
- [[Loyality_Coupons_Models sharedMyData]
- getNewsWith:@"698"
- onSuccess:^(NSArray *data) {
- [shops_array addObjectsFromArray:data];
- [self.KOTableViewWithClients reloadData];
- NSLog(@"shops array %@",shops_array);
- } onFailure:^(NSError *error, NSInteger statusCode) {
- NSLog(@"error = %@ code = %ld", [error localizedDescription], statusCode);
- }];
- }
- -(void) getPartneFromServer {
- [[Loyality_Coupons_Models sharedPartner]
- getPartnersWith:@"698"
- onSuccess:^(NSArray *data) {
- [partners_info_array addObjectsFromArray:data];
- [self.KOTableViewWithClients reloadData];
- NSLog(@"partners_info_array %@",partners_info_array);
- } onFailure:^(NSError *error, NSInteger statusCode) {
- NSLog(@"error = %@ code = %ld", [error localizedDescription], statusCode);
- }];
- }
- - (IBAction)map_or_list:(id)sender {
- if (self.segmentedMapList.selectedSegmentIndex == 0){
- }else if (self.segmentedMapList.selectedSegmentIndex == 1){
- MKMapView *mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
- mapView.showsUserLocation = YES;
- mapView.showsBuildings = YES;
- [self.view addSubview:mapView];
- }
- }
- - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
- {
- MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
- [self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
- MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
- point.coordinate = userLocation.coordinate;
- point.title = @"hey";
- [self.mapView addAnnotation:point];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return partners_info_array.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- // KOMainCell *OKCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KOMainCell class]) forIndexPath:indexPath];
- UITableViewCell *OKCell = [KOTableViewWithClients dequeueReusableCellWithIdentifier:@"Cell"];
- NSLog(@"partners array = %@",partners_info_array);
- logos = [partners_info_array objectAtIndex:3];
- brand = [partners_info_array objectAtIndex:2];
- NSLog(@"logos = %@",logos);
- // [cell.backgroundImageView setImageWithURL:[NSURL URLWithString:[@"http://api-test.idiscount.by" stringByAppendingString:tempCoupon.imageURL]]];
- // [OKCell.KOImageLogo setImageWithURL:[NSURL URLWithString:[@"http://api-test.idiscount.by" stringByAppendingString:[logos objectAtIndex:2]]]];
- NSString *brands1_string = [brand objectAtIndex:0];
- NSString *brands2_string = [brand objectAtIndex:1];
- NSString *brands3_string = [brand objectAtIndex:2];
- NSArray *allBrands = [NSArray arrayWithObjects:brands1_string,brands2_string,brands3_string, nil];
- NSLog(@"all brands %lu",(unsigned long) allBrands.count);
- OKCell.textLabel.text = [allBrands objectAtIndex:indexPath.row];
- NSLog(@"row %ld",(long)indexPath.row);
- return OKCell;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement