我正在使用foursquare iOS api开发iOS应用程序,我想获得附近推荐的场所。我用下面的代码,它给我一个空的结果..我在哪里做错了? ? ?

NSArray* venues;

//get the foursquare locations
- (void)getTipsForLocation:(CLLocation *)location {

//NSLog(@"lat %f",location.coordinate.latitude);

 [Foursquare2 venueExploreRecommendedNearByLatitude:@(location.coordinate.latitude)
                                         longitude:@(location.coordinate.longitude)
                                              near:nil
                                        accuracyLL:nil
                                          altitude:nil
                                       accuracyAlt:nil
                                             query:nil
                                             limit:nil
                                            offset:nil
                                            radius:@(1500)
                                           section:nil
                                           novelty:nil
                                    sortByDistance:1
                                           openNow:0
                                       venuePhotos:0
                                             price:nil
                                          callback:^(BOOL success, id result){
                                              if (success) {
                                                  NSDictionary *dic = result;
                                                  venues = [dic valueForKeyPath:@"response.venues"];
                                                  FSConverter *converter = [[FSConverter alloc]init];
                                                  self.nearbyVenues = [converter convertToObjects:venues];


                                                  //NSLog(@"venues %@",venues);
                                                  //NSLog(@"near by places %@",self.nearbyVenues);
                                              }
                                              else{
                                                  NSLog(@" foursquare connecting error");
                                              }

                                          }];


 NSLog(@"recommended place array %@",venues);
}

最佳答案

您不能在NSNumber和NSString中传递Nil。

NSNumber *emptynumber=[[NSNumber alloc] init];

[Foursquare2 venueExploreRecommendedNearByLatitude:lan longitude:lon near:@"" accuracyLL:emptynumber altitude:emptynumber accuracyAlt:emptynumber query:@"" limit:emptynumber offset:emptynumber radius:@(1500) section:@"" novelty:@"" sortByDistance:YES openNow:YES venuePhotos:YES price:@"" callback:^(BOOL success, id result) {

    if (success) {
        NSLog(@"secondResult: %@",result);
        NSDictionary *dic = result;
        NSArray *venues = [dic valueForKeyPath:@"response.venues"];
        FSConverter *converter = [[FSConverter alloc] init];
        self.venues = [converter convertToObjects:venues];



            [self.tableView reloadData];

        NSLog(@"Data: %@",venues);
    }

}];


这个对我有用。

09-25 17:19