这是我获取邮政编码的代码。
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);
}];
但它始终因NSInvalidArgumentException
错误而崩溃,
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'
答案 0 :(得分:-1)
bytes是NSData的属性,因此您将NSDictionary用作NSData。