Swift 从通讯簿获取kABAddressCountryCodeKey

Swift 从通讯簿获取kABAddressCountryCodeKey,swift,macos,cocoa,addressbook,Swift,Macos,Cocoa,Addressbook,我有这个代码,可以从我的osx地址簿中获取特定人的国家/地区 let address = person.value(forProperty: kABAddressProperty) as? ABMultiValue print(((adresse?.value(at: 0) as? NSMutableDictionary)?.value(forKey: kABAddressCountryKey) as? String) ?? "No Country") print(((adresse?.va

我有这个代码,可以从我的osx地址簿中获取特定人的国家/地区

let address = person.value(forProperty: kABAddressProperty) as? ABMultiValue

print(((adresse?.value(at: 0) as? NSMutableDictionary)?.value(forKey: kABAddressCountryKey) as? String) ?? "No Country")

print(((adresse?.value(at: 0) as? NSMutableDictionary)?.value(forKey: kABAddressCountryCodeKey) as? String) ?? "No Country")
kABAddressCountryKey的打印结果将是完整的国家/地区。 但是我想要国家代码钥匙。但是对于第二次打印结果,我没有得到任何国家


我忘了什么?我想你什么也没忘。我只是反复浏览了我的联系人,在我与国家的2020个地址中,1368个没有国家代码


我只是做了一个快速测试,在macOS Sierra Contacts应用程序中添加的联系人没有获得国家代码,而在iOS 11 Contacts应用程序中添加的联系人获得了国家代码。

sry。英语不是我的主要语言。我尽我最大的努力…我在第一篇文章中改变了它