From 167ab64bf48adacfdfd2bc864199253e0741de09 Mon Sep 17 00:00:00 2001 From: Umar Date: Sat, 20 Feb 2016 15:57:43 -0500 Subject: [PATCH 1/4] commit --- .../FixaDaApp/Base.lproj/Main.storyboard | 18 ++-- FixaDaApp/FixaDaApp/ViewController.m | 19 +++- FixaDaApp/FixaDaApp/mapTableViewController.h | 13 +++ FixaDaApp/FixaDaApp/mapTableViewController.m | 101 ++++++++++++++++++ 4 files changed, 139 insertions(+), 12 deletions(-) create mode 100644 FixaDaApp/FixaDaApp/mapTableViewController.h create mode 100644 FixaDaApp/FixaDaApp/mapTableViewController.m diff --git a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard index ed571b5..3de59a7 100644 --- a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard +++ b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -19,24 +19,24 @@ - + - + - + - + @@ -48,7 +48,7 @@ - + diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index f938005..5084764 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -39,11 +39,22 @@ - (void)viewDidLoad { self.mapView.delegate = self; self.locationManager = [[CLLocationManager alloc] init]; + + self.mapView.showsUserLocation = YES; + + //just added + [self.tableView reloadData]; + +// [self fetchVenuesAtLocation:location]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + + [self.locationManager requestWhenInUseAuthorization]; + + } @@ -56,7 +67,8 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 0; + //added this line + return self.venues.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath @@ -94,7 +106,7 @@ - (void)zoomToLocation:(CLLocation *)location - (void)fetchVenuesAtLocation:(CLLocation *)location { __weak typeof(self) weakSelf = self; - [FoursquareAPIManager findSomething:@"music" + [FoursquareAPIManager findSomething:@"venues" atLocation:location completion:^(NSArray *data){ @@ -107,7 +119,8 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location - (void)showPins { - [self.mapView removeAnnotations:self.mapView.annotations]; + //removed this line + //[self.mapView removeAnnotations:self.mapView.annotations]; for (NSDictionary *venue in self.venues) { double lat = [venue[@"location"][@"lat"] doubleValue]; diff --git a/FixaDaApp/FixaDaApp/mapTableViewController.h b/FixaDaApp/FixaDaApp/mapTableViewController.h new file mode 100644 index 0000000..314a63f --- /dev/null +++ b/FixaDaApp/FixaDaApp/mapTableViewController.h @@ -0,0 +1,13 @@ +// +// mapTableViewController.h +// FixaDaApp +// +// Created by Umar on 2/20/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface mapTableViewController : UITableViewController + +@end diff --git a/FixaDaApp/FixaDaApp/mapTableViewController.m b/FixaDaApp/FixaDaApp/mapTableViewController.m new file mode 100644 index 0000000..dc1ee6c --- /dev/null +++ b/FixaDaApp/FixaDaApp/mapTableViewController.m @@ -0,0 +1,101 @@ +// +// mapTableViewController.m +// FixaDaApp +// +// Created by Umar on 2/20/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "mapTableViewController.h" + +@interface mapTableViewController () + +@end + +@implementation mapTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { +#warning Incomplete implementation, return the number of sections + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +#warning Incomplete implementation, return the number of rows + + + + return 5; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mapCell" forIndexPath:indexPath]; + + // Configure the cell... + + return cell; +} + + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end From c875389b9b1e2ea1f8330433660af456db696a29 Mon Sep 17 00:00:00 2001 From: Umar Date: Sat, 20 Feb 2016 17:59:58 -0500 Subject: [PATCH 2/4] update --- FixaDaApp/FixaDaApp/ViewController.m | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index 5084764..b2db175 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -33,6 +33,10 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; + self.venues = [[NSArray alloc] init]; + + self.foundPlaces = NO; + self.tableView.delegate = self; self.tableView.dataSource = self; @@ -42,10 +46,22 @@ - (void)viewDidLoad { self.mapView.showsUserLocation = YES; +// [self fetchVenuesAtLocation:userLocation.location]; + + +// self.foundPlaces = YES; + + //just added [self.tableView reloadData]; // [self fetchVenuesAtLocation:location]; + +// [self fetchVenuesAtLocation:]; + + [self showPins]; + + [self mapView]; } - (void)viewDidAppear:(BOOL)animated @@ -53,11 +69,9 @@ - (void)viewDidAppear:(BOOL)animated [super viewDidAppear:animated]; [self.locationManager requestWhenInUseAuthorization]; - - + } - # pragma mark - Table view datasource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView @@ -113,8 +127,11 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location weakSelf.venues = data; [weakSelf.tableView reloadData]; [weakSelf showPins]; - + //added line + [weakSelf mapView]; }]; + //added line +// [self mapView]; } - (void)showPins @@ -129,7 +146,11 @@ - (void)showPins MKPointAnnotation *point = [[MKPointAnnotation alloc] init]; point.coordinate = CLLocationCoordinate2DMake(lat, lng); [self.mapView addAnnotation:point]; + //added line + point.title = venue[@"name"]; + } + } @end From a55d3407852f45e957de42a5221ae8e081cd4f4f Mon Sep 17 00:00:00 2001 From: Umar Date: Sun, 21 Feb 2016 08:16:41 -0500 Subject: [PATCH 3/4] commit --- FixaDaApp/FixaDaApp/FoursquareAPIManager.m | 2 +- FixaDaApp/FixaDaApp/Info.plist | 5 +++++ FixaDaApp/FixaDaApp/ViewController.m | 18 +++++++++--------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m index b0ee3ac..57fc520 100644 --- a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m +++ b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m @@ -39,7 +39,7 @@ + (void)findSomething:(NSString *)query progress:nil success:^(NSURLSessionTask *task, id responseObject) { - + completion([[responseObject objectForKey:@"response"] objectForKey:@"venues"]); } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error: %@", error); diff --git a/FixaDaApp/FixaDaApp/Info.plist b/FixaDaApp/FixaDaApp/Info.plist index cf463a3..3012ccb 100644 --- a/FixaDaApp/FixaDaApp/Info.plist +++ b/FixaDaApp/FixaDaApp/Info.plist @@ -4,6 +4,11 @@ NSLocationWhenInUseUsageDescription Show you the places! + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + CFBundleDevelopmentRegion en CFBundleExecutable diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index b2db175..d358eda 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -33,9 +33,9 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - self.venues = [[NSArray alloc] init]; + //self.venues = [[NSArray alloc] init]; - self.foundPlaces = NO; +// self.foundPlaces = NO; self.tableView.delegate = self; self.tableView.dataSource = self; @@ -53,15 +53,15 @@ - (void)viewDidLoad { //just added - [self.tableView reloadData]; +// [self.tableView reloadData]; // [self fetchVenuesAtLocation:location]; // [self fetchVenuesAtLocation:]; - [self showPins]; + //[self showPins]; - [self mapView]; + //[self mapView]; } - (void)viewDidAppear:(BOOL)animated @@ -120,7 +120,7 @@ - (void)zoomToLocation:(CLLocation *)location - (void)fetchVenuesAtLocation:(CLLocation *)location { __weak typeof(self) weakSelf = self; - [FoursquareAPIManager findSomething:@"venues" + [FoursquareAPIManager findSomething:@"Venues" atLocation:location completion:^(NSArray *data){ @@ -128,7 +128,7 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location [weakSelf.tableView reloadData]; [weakSelf showPins]; //added line - [weakSelf mapView]; + //[weakSelf mapView]; }]; //added line // [self mapView]; @@ -137,7 +137,7 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location - (void)showPins { //removed this line - //[self.mapView removeAnnotations:self.mapView.annotations]; + [self.mapView removeAnnotations:self.mapView.annotations]; for (NSDictionary *venue in self.venues) { double lat = [venue[@"location"][@"lat"] doubleValue]; @@ -147,7 +147,7 @@ - (void)showPins point.coordinate = CLLocationCoordinate2DMake(lat, lng); [self.mapView addAnnotation:point]; //added line - point.title = venue[@"name"]; +// point.title = venue[@"name"]; } From 6c79925dda2830eeb32409ca979edab22223bd96 Mon Sep 17 00:00:00 2001 From: Umar Date: Sun, 21 Feb 2016 08:19:07 -0500 Subject: [PATCH 4/4] new commit --- FixaDaApp/FixaDaApp/ViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index d358eda..751bfac 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -120,7 +120,7 @@ - (void)zoomToLocation:(CLLocation *)location - (void)fetchVenuesAtLocation:(CLLocation *)location { __weak typeof(self) weakSelf = self; - [FoursquareAPIManager findSomething:@"Venues" + [FoursquareAPIManager findSomething:@"music" atLocation:location completion:^(NSArray *data){