This is my code for getting postal code.
CLGeocoder *reverseGeocoder = [[CLGeocoder alloc] init];
[reverseGeocoder reverseGeocodeLocation:locationManager.location completionHandler:^(NSArray *placemarks, NSError *error)
{
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
return;
}
NSLog(@"Received placemarks: %@", placemarks);
CLPlacemark *myPlacemark = [placemarks objectAtIndex:0];
NSString *countryCode = myPlacemark.ISOcountryCode;
NSString *countryName = myPlacemark.country;
NSLog(@"My country code: %@ and countryName: %@", countryCode, countryName);
}];
But its always crashing with NSInvalidArgumentException
error,
2017-02-07 12:29:58.124 CBB[3654:270750] Lat : 42.771389 Long :
129.423340
2017-02-07 12:29:58.967 CBB[3654:270750] -[__NSDictionaryI bytes]: unrecognized selector sent to instance 0x600000473b80
2017-02-07 12:29:59.011 CBB[3654:270750] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI bytes]: unrecognized selector sent to instance 0x600000473b80'