1

This code I am using to get the entire Address of the user using Reverse Geolocation. Can someone suggest me the way to just get the Postal Code or Zip code out of it .

//Geocoding Block
[self.geoCoder reverseGeocodeLocation: locationManager.location completionHandler:
 ^(NSArray *placemarks, NSError *error) {

     //Get nearby address
     CLPlacemark *placemark = [placemarks objectAtIndex:0];


     //String to hold address
     NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];


     //Print the location to console
     NSLog(@"I am currently at %@",locatedAt);

     //Set the label text to current location
     [locationLabel setText:locatedAt];

 }];
dreamcrash
  • 47,137
  • 25
  • 94
  • 117
Akshat Anil
  • 63
  • 1
  • 7
  • have you checked what's inside `placemark.addressDictionary`? I'd imagine there is a key for zipcode. – mkral Dec 20 '12 at 22:50
  • there is a documents present for this on Apple Dev http://developer.apple.com/library/IOs/#documentation/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html , can but i lacks proper documentation . its is suppose to be placemark.postalCode.... – Akshat Anil Dec 20 '12 at 22:55
  • iOSRider has an answer in this question which shows how to get the Zip / Post Code: http://stackoverflow.com/q/5058798/558933 – Robotic Cat Dec 20 '12 at 22:55
  • @RoboticCat is it necessary to cast it? – mkral Dec 20 '12 at 23:04
  • not sure ? and the above link is not working fine . – Akshat Anil Dec 20 '12 at 23:06

1 Answers1

0

Use google maps to convert the geo location to a zip adress.

https://developers.google.com/maps/documentation/geocoding/

Jordi Kroon
  • 2,607
  • 3
  • 31
  • 55