iOS - MKMapKit, show address of the users location in annotation

1.7k views Asked by At

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?

1

There are 1 answers

0
AudioBubble On BEST ANSWER

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