iosfoursquarecurrentlocation

Foursquare iPhone API nearby places


I'm new to Foursquare API and I couldn't figure out how to get nearby places given the current location? I looked at a lot of samples about this but I couldn't make it work.


Solution

  • see this link https://github.com/Constantine-Fry/Foursquare-API-v2/tree/master/Foursquare2-iOS . It's easy to integrate the foursquare API for iPhone. I have used this one.

    For example:Place Search

    [Foursquare2 searchVenuesNearByLatitude:@"40.763" longitude:@"-73.990" accuracyLL:nil altitude:nil accuracyAlt:nil query:@"" limit:@"15" intent:@"" callback:^(BOOL success, id result){
                if (success) {
                 //parse here
                 tableData = [[FoursquareParser parseSearchVenuesResultsDictionary:(NSDictionary*)result] retain];
                [mTableView reloadData];
               }
            }];
    

    //Search Venues Parser

     +(NSMutableArray*)parseSearchVenuesResultsDictionary:(NSDictionary*)result{
        NSArray *groupsArray = [[result objectForKey:@"response"] objectForKey:@"venues"];
        if([groupsArray count] > 0){
    
                NSMutableArray *resultArray = [NSMutableArray array];
        //Get Stats details
                    NSDictionary *stats = [[groupsArray objectAtIndex:i] objectForKey:@"stats"];
                    [resultDictionary setObject:[stats objectForKey:@"checkinsCount"] forKey:@"checkinsCount"];
                    [resultDictionary setObject:[stats objectForKey:@"tipCount"] forKey:@"tipCount"];
                    [resultDictionary setObject:[stats objectForKey:@"usersCount"] forKey:@"usersCount"];
    
                    [resultArray addObject:resultDictionary];
                    return resultArray;
            }
            return [NSMutableArray array];
        }