문제

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];

 }
도움이 되었습니까?

해결책

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;

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top