This is how you can access an NSArray
of the different venues:
NSArray* locationsArray = jsonDictionary[@"response"][@"venues"];
From there you have access to all the location data. I would create a new model class for these locations with a CLLocation
property to store the longitude and latitude as well as a distance property. Iterate through the array and instantiate the models while also calculating the distance from the device's current location:
NSMutableArray *locationObjectsArray;
for (NSDictionary *locationDict in locationsArray)
{
Location *newLocation = [Location alloc] initWith...];
newLocation.distance = [newLocation.coordinate distanceFromLocation:deviceLocation];
[locationObjectsArray addObject:newLocation];
}
NSArray * results = [sortedLocations sortedArrayUsingDescriptors:@[[[NSSortDescriptor alloc] initWithKey:@"distance"
ascending:YES]]];
This should give you an array of locations sorted by distance from the device which you can now display in a table.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…