gpt4 book ai didi

ios - 如何从 AddressDictionary 获取格式化地址 NSString?

转载 作者:IT王子 更新时间:2023-10-29 08:21:15 24 4
gpt4 key购买 nike

尝试从 AddressDictionary 获取格式化地址,我从 CLGeocoder 获取了该地址。使用以下代码没有结果:

subtitle = [NSString stringWithString:[[addressDict objectForKey:@"FormattedAddressLines"]objectAtIndex:0]];

还试过:

subtitle = [[[ABAddressBook sharedAddressBook] formattedAddressFromDictionary:placemark.addressDictionary] string];

但这段代码似乎只能在 Mac OS X 上运行。

编译器询问 ABAdressBook,但我已导入两个头文件。

#import <AddressBook/ABAddressBook.h>
#import <AddressBook/AddressBook.h>

最佳答案

addressDictionary 属性的文档说:

You can format the contents of this dictionary to get a full address string as opposed to building the address yourself. To format the dictionary, use the ABCreateStringWithAddressDictionary function as described in Address Book UI Functions Reference.

因此添加并导入 AddressBookUI 框架并尝试:

subtitle = 
ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO);

关于ios - 如何从 AddressDictionary 获取格式化地址 NSString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7848291/

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