1
我在嘗試在iOS 6中查找聯繫人地址時遇到了一個非常奇怪的問題,除非聯繫人具有標有「地址」的地址,我找不到它。在「工作」或「主頁」下輸入的任何地址都不會出現。在iOS6中記錄爲聯繫人存儲的每個值
爲了試圖找出這個問題,是否有可能從聯繫人中提取人員記錄並只轉儲存儲的每個值?我希望這將幫助我找到那些「家庭」和「工作」地址的生活地點。
這裏是我到目前爲止的代碼:
- (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);
}
謝謝戴夫!原來地址沒有存儲在主要聯繫人中,並且它沒有顯示的原因是因爲地址存儲在同名的另一個聯繫人中。統一信息已經打開,我沒有意識到。 –