我遇到了一个非常奇怪的问题,我试图在 iOS 6 中查找联系人的地址,除非该联系人的地址标有“地址”,否则我找不到它。在“工作”或“家庭”下输入的任何地址都不会出现。
为了解决这个问题,是否可以从联系人中获取人员记录并转储存储的每个值?我希望这能帮助我找到那些“家庭”和“工作”地址的居住地。
到目前为止,这是我的代码:
- (void)setAddressFromPerson:(ABRecordRef)person
{
ABMultiValueRef addresses = ABRecordCopyValue(person, kABPersonAddressProperty);
for (CFIndex j = 0; j<ABMultiValueGetCount(addresses);j++){
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(addresses, j);
CFStringRef typeTmp = ABMultiValueCopyLabelAtIndex(addresses, j);
CFStringRef labeltype = ABAddressBookCopyLocalizedLabel(typeTmp);
NSString *street = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressStreetKey) copy];
NSString *city = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressCityKey) copy];
NSString *state = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressStateKey) copy];
NSString *zip = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressZIPKey) copy];
NSString *country = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressCountryKey) copy];
NSLog(street);
}