Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use MKReverseGeocoder from 3.0 through 5.0. Since 5.0 MKReverseGeocoder is depreciated and usage of CLGeocoder is advised.</p> <p>You should use CLGeocoder if available. In order to be able to extract address information you would have to include Address Book framework.</p> <pre><code>#import &lt;AddressBookUI/AddressBookUI.h&gt; #import &lt;CoreLocation/CLGeocoder.h&gt; #import &lt;CoreLocation/CLPlacemark.h&gt; - (void)reverseGeocodeLocation:(CLLocation *)location { CLGeocoder* reverseGeocoder = [[CLGeocoder alloc] init]; if (reverseGeocoder) { [reverseGeocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { CLPlacemark* placemark = [placemarks firstObject]; if (placemark) { //Using blocks, get zip code NSString* zipCode = [placemark.addressDictionary objectForKey:(NSString*)kABPersonAddressZIPKey]; } }]; }else{ MKReverseGeocoder* rev = [[MKReverseGeocoder alloc] initWithCoordinate:location.coordinate]; rev.delegate = self;//using delegate [rev start]; //[rev release]; release when appropriate } //[reverseGeocoder release];release when appropriate } </code></pre> <p>MKReverseGeocoder delegate method:</p> <pre><code>- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { //Get zip code NSString* zipCode = [placemark.addressDictionary objectForKey:(NSString*)kABPersonAddressZIPKey]; } </code></pre> <p>MKReverseGeocoder and ABPersonAddressZIPKey were deprecated in iOS 9.0. Instead the <code>postalcode</code> property of the <code>CLPlacemark</code> can be used to get zip code:</p> <pre><code>NSString * zipCode = placemark.postalCode; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload