diff --git a/.gitignore b/.gitignore index 79d9331..13e6513 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,5 @@ Carthage/Build fastlane/report.xml fastlane/screenshots + +.DS_Store diff --git a/FixaDaApp/.DS_Store b/FixaDaApp/.DS_Store new file mode 100644 index 0000000..ec01fea Binary files /dev/null and b/FixaDaApp/.DS_Store differ diff --git a/FixaDaApp/FixaDaApp/Base.lproj/LaunchScreen.storyboard b/FixaDaApp/FixaDaApp/Base.lproj/LaunchScreen.storyboard index 2e721e1..90d6157 100644 --- a/FixaDaApp/FixaDaApp/Base.lproj/LaunchScreen.storyboard +++ b/FixaDaApp/FixaDaApp/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -15,7 +16,6 @@ - diff --git a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard index ed571b5..f2c0ca6 100644 --- a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard +++ b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard @@ -18,25 +18,25 @@ - - + + - + - + - + @@ -48,7 +48,7 @@ - + diff --git a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m index b0ee3ac..00a2bf2 100644 --- a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m +++ b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m @@ -28,23 +28,31 @@ @implementation FoursquareAPIManager + (void)findSomething:(NSString *)query atLocation:(CLLocation *)location completion:(void(^)(NSArray *data))completion + { NSString *baseURL = @"https://api.foursquare.com/v2/venues/search"; NSString *url = [NSString stringWithFormat:@"%@?client_id=%@&client_secret=%@&v=20160215&ll=%f,%f&query=%@", baseURL, kFoursquareAPIClientID, kFoursquareAPIClientSecret, location.coordinate.latitude, location.coordinate.longitude, query]; + //NSLog(@"%@", url); + AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; [manager GET:url parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) - { - - } failure:^(NSURLSessionTask *operation, NSError *error) - { - NSLog(@"Error: %@", error); - }]; - + { + NSDictionary *response = (NSDictionary *)responseObject; + NSArray *venues = response[@"response"][@"venues"]; + + completion(venues); + + } failure:^(NSURLSessionTask *operation, NSError *error) + { + NSLog(@"Error: %@", error); + }]; + } + @end diff --git a/FixaDaApp/FixaDaApp/Info.plist b/FixaDaApp/FixaDaApp/Info.plist index cf463a3..5af4001 100644 --- a/FixaDaApp/FixaDaApp/Info.plist +++ b/FixaDaApp/FixaDaApp/Info.plist @@ -2,6 +2,11 @@ + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSLocationWhenInUseUsageDescription Show you the places! CFBundleDevelopmentRegion diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index f938005..fc94db0 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -8,8 +8,10 @@ #import "ViewController.h" #import +#import #import "FoursquareAPIManager.h" + @interface ViewController () < UITableViewDataSource, @@ -36,14 +38,17 @@ - (void)viewDidLoad { self.tableView.delegate = self; self.tableView.dataSource = self; + self.locationManager = [[CLLocationManager alloc] init]; self.mapView.delegate = self; + self.mapView.showsUserLocation = YES; - self.locationManager = [[CLLocationManager alloc] init]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + + [self.locationManager requestWhenInUseAuthorization]; } @@ -56,18 +61,20 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 0; + return self.venues.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BeepBoopCellIdentifier"]; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BeepBoopCellIdentifier" forIndexPath:indexPath]; NSDictionary *venue = self.venues[indexPath.row]; NSString *name = venue[@"name"]; cell.textLabel.text = name; return cell; + + } # pragma mark - Map view delegate @@ -119,4 +126,5 @@ - (void)showPins } } + @end