diff --git a/.gitignore b/.gitignore index 79d9331..e49df55 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore +.DS_Store + ## Build generated build/ DerivedData @@ -44,7 +46,7 @@ Carthage/Build # fastlane # -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the # screenshots whenever they are needed. # For more information about the recommended setup visit: # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md diff --git a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard index ed571b5..64ce424 100644 --- a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard +++ b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -19,24 +19,24 @@ - + - + - + - + @@ -48,7 +48,7 @@ - + diff --git a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m index b0ee3ac..9d42864 100644 --- a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m +++ b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m @@ -39,6 +39,10 @@ + (void)findSomething:(NSString *)query progress:nil success:^(NSURLSessionTask *task, id responseObject) { + NSDictionary *response = [responseObject objectForKey:@"response"]; + NSArray *venues = [response objectForKey:@"venues"]; + //NSLog(@"%@", venues); + completion(venues); } failure:^(NSURLSessionTask *operation, NSError *error) { diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index f938005..c8628f0 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -37,6 +37,7 @@ - (void)viewDidLoad { self.tableView.dataSource = self; self.mapView.delegate = self; + self.mapView.showsUserLocation = YES; self.locationManager = [[CLLocationManager alloc] init]; } @@ -44,6 +45,7 @@ - (void)viewDidLoad { - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + [self.locationManager requestWhenInUseAuthorization]; } @@ -56,7 +58,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 0; + return self.venues.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath @@ -64,6 +66,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BeepBoopCellIdentifier"]; NSDictionary *venue = self.venues[indexPath.row]; + NSLog(@"%@", self.venues); NSString *name = venue[@"name"]; cell.textLabel.text = name; @@ -99,9 +102,16 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location completion:^(NSArray *data){ weakSelf.venues = data; - [weakSelf.tableView reloadData]; - [weakSelf showPins]; + //NSLog(@"I'm printing from inside the completion block! \n%@", weakSelf.venues); + // just in case this is running on another thread, we get + // back on the main thread to change the UI + dispatch_async(dispatch_get_main_queue(), ^{ + + // Back on the main thread, ask the tableview to reload itself. + [weakSelf.tableView reloadData]; + [weakSelf showPins]; + }); }]; }