I have this code to get the country of a specific person from my osx address book.
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")
The print result for kABAddressCountryKey will be the complete country. but I would like to have the country code key. But for the second print result I get "No Country"
what did I forget?
I don't think you forgot anything. I just iterated through my contacts, and of the 2,020 addresses I had with countries, 1,368 had no country code.
I just did a quick test and a contact added in macOS Sierra Contacts app did not get country code, whereas contact added in iOS 11 Contacts app did.