我有位置管理器的经度和纬度,现在我正在尝试反转地理代码,以将该信息转换为地址字符串。我找到了下面的代码,据称可以做到这一点,但我收到了链接器错误。我认为这意味着我缺少一些框架或其他东西。我无法找到答案。任何人都可以帮忙吗?
错误:
Apple Mach-O Linker Error
"_KABPersonAddressZIPKey", referenced from:
对于我要生成的每个字符串,依此类推。
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:latitude
longitude:longitude];
[geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error)
{
if (error) {
NSLog(@"Geocode failed with error: %@", error);
return;
}
if (placemarks && placemarks.count > 0)
{
CLPlacemark *placemark = placemarks[0];
NSDictionary *addressDictionary = placemark.addressDictionary;
NSString *address = [addressDictionary objectForKey:(NSString *)kABPersonAddressStreetKey];
NSString *city = [addressDictionary objectForKey:(NSString *)kABPersonAddressCityKey];
NSString *state = [addressDictionary objectForKey:(NSString *)kABPersonAddressStateKey];
NSString *zip = [addressDictionary objectForKey:(NSString *)kABPersonAddressZIPKey];
NSLog(@"%@ %@ %@ %@", address,city, state, zip);
}
}
];