Reverse Geocode - return locality
I'm having trouble returning a city using reverse geocoding in Objective C
on iOS. I'm able to log the city within the completionHandler, but I can't
seem to figure out how to return it as a string if it's called from
another function.
The city variable is an NSString created in the header file.
- (NSString *)findCityOfLocation:(CLLocation *)location
{
geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray
*placemarks, NSError *error) {
if ([placemarks count])
{
placemark = [placemarks objectAtIndex:0];
city = placemark.locality;
}
}];
return city;
}
No comments:
Post a Comment