Forever a noob Forever a noob - 4 months ago 47
iOS Question

Zip code from current location in objective c?

I've been googling around a little bit, but i can't seem to find code snippets that can give me the zip code of the current location from an iOS device without any use of API's and such. Most answers regarding the topic are using deprecated classes. And if this is possible, will it only get zip codes from the US or other countries in Europe aswell?

Any help would be greatly appreciated. :)

Answer

Since MKReverseGeocoder is deprecated in iOS 5, now it's CLGeocoder. You could create a CLGeocoder object and, with a previously-created CLLocation object with the coordinates, use the following method:

- (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler

Here is an example and Document.