I'm trying to get the full zip code through my location using GPS from my cell in Objective-C , but it returns only 5 digits. I used the following code snippet:
NSString *cepcompleto = [NSString stringWithFormat:@"%@-%@", placemark.postalCode, [placemark.addressDictionary objectForKey:@"PostCodeExtension"]];
The rest of the code follows:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocation *currentLocation = newLocation;
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
if (error == nil && [placemarks count] > 0) {
placemark = [placemarks lastObject];
NSString *cepcompleto = [NSString stringWithFormat:@"%@-%@", placemark.postalCode, [placemark.addressDictionary objectForKey:@"PostCodeExtension"]];
digitoCep = [placemark.addressDictionary objectForKey:@"PostCodeExtension"];
cepEstatico = cepcompleto;
[vg setCep];
} else {
NSLog(@"%@", error.debugDescription);
}
}];
[manager startUpdatingLocation];
}