从联系人获取多个地址? (ABRecordRef)

时间:2012-09-17 12:35:03

标签: iphone objective-c ipad contacts abrecord

我正在尝试从我的联系人那里获取一个选定个人的地址。

我正在使用ABPeoplePickerNavigationController和此委托方法在选择某人时获取电子邮件和姓名等数据:

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

但是,我怎样才能获得一个人的地址(或者一个人的多个地址,如果他们有多个地址)?我需要单独获取每个地址并分成几部分,例如地址行1,2,城市,州,邮政编码,国家。

1 个答案:

答案 0 :(得分: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;