3
I’m trying to get the full zip code through my location using the GPS of my mobile 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"]];
Follow the rest of the code:
- (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];
}
Five digits? Looks like the American standard. Really I don’t know what this object is
placemark.addressDictionary
, post more code details, this is an API?– Guilherme Nascimento
Perhaps the additional information of this answer help you.
– Paulo Rodrigues
Yes it is an API, I found some examples similar to mine, but it was occurring the same problem, in certain points it displayed the complete cep.
– Bruno Richart