Question

By default on a map view we can show the user's location. On tapping the annotation pin, it will show "Current Location". But I want to show the address of the user as street, city and country. How can I do it by using CLGeoCoder class?

Was it helpful?

Solution

Do something like this:

CLGeocoder *gc = [[[CLGeocoder alloc] init] autorelease];
[gc reverseGeocodeLocation:locationObject completionHandler:^(NSArray *placemark, NSError *error) {
    CLPlacemark *pm = [placemark objectAtIndex:0];
    NSDictionary *address = pm.addressDictionary;
    // do something with the address, see keys in the remark below
}];

And the relevant docs here: http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html#//apple_ref/occ/instp/CLPlacemark/addressDictionary

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top