2012-09-17 35 views
0

我很努力地從我的聯繫人中獲取單個選定個人的地址。從聯繫人獲取多個地址? (ABRecordRef)

我使用ABPeoplePickerNavigationController與此委託方法對一人的選擇機會,獲得像電子郵件和名稱數據:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person

但我怎麼能得到一個人(或多個地址的地址一個人應該有多個)?我需要單獨獲取每個地址,並將其分解成部分地址,如地址1,2,城市,州,郵政編碼,國家。

任何幫助將不勝感激,謝謝。

回答

0

這裏你如何獲得該人的地址屬性。地址屬性常量

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *) 
      peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 
      property:(ABPropertyID)property 
      identifier:(ABMultiValueIdentifier)identifier{ 

      NSString *string = (NSString*)ABRecordCopyValue(person, AddressPropertyHere); 
} 

列表:

const ABPropertyID kABPersonAddressProperty; 
const CFStringRef kABPersonAddressStreetKey; 
const CFStringRef kABPersonAddressCityKey; 
const CFStringRef kABPersonAddressStateKey; 
const CFStringRef kABPersonAddressZIPKey; 
const CFStringRef kABPersonAddressCountryKey; 
const CFStringRef kABPersonAddressCountryCodeKey; 
+0

我已經試過這樣:'的NSString *街道=(__bridge的NSString *)ABRecordCopyValue(人,kABPersonAddressStreetKey);'和崩潰的應用程序。此外,我得到一個警告說:「不兼容指針整數轉換傳遞'const CFStringRef'(又名'const結構__CFString * const')到類型'ABPropertyID'(又名'int')的參數。 '最後,如果一個聯繫人有多個地址,我該如何獲得這樣的多個地址? –

+0

用int代替NSString。 – janusbalatbat

相關問題