gpt4 book ai didi

iphone - 当我从经度和纬度创建位置字符串时,为什么在 iOS 中会出现此链接器错误?

转载 作者:可可西里 更新时间:2023-11-01 05:02:26 24 4
gpt4 key购买 nike

我有来自位置管理器的经度和纬度,现在我正在尝试反向地理编码,以将该信息转换为地址字符串。我找到了下面的代码,据称可以执行此操作,但我遇到了链接器错误。我认为这意味着我缺少一些框架或其他东西。我找不到答案。谁能帮忙?

错误:

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);

}
}
];

最佳答案

在文档中查找 kABPersonAddressStreetKey:

http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html

它在顶部说它在 AddressBook 框架中。所以你需要链接到那个。

关于iphone - 当我从经度和纬度创建位置字符串时,为什么在 iOS 中会出现此链接器错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13115706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com