iosobjective-cmkmapviewmkplacemark

iOS: How do I get zip code from a placemark


I am wondering how I might be able to get the placemark's zip code in iOS. Any tips or suggestions will be deeply appreciated. Here is the code I have so far, I am able to get the city.

 - (void)recenterMapToPlacemark:(CLPlacemark *)placemark {
MKCoordinateRegion region;
MKCoordinateSpan span;

span.latitudeDelta = 0.02;
span.longitudeDelta = 0.02;

region.span = span;
region.center = placemark.location.coordinate;

NSString *city = [placemark locality];

 }

Solution

  • Check the documentation here: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html#//apple_ref/occ/instp/CLPlacemark/postalCode

    It is the postalCode property you are looking for.
    So in your case it is:

    NSString *zipCode = placemark.postalCode;