【问题标题】:Get Multiple Addresses From Contacts? (ABRecordRef)从联系人获取多个地址? (ABRecordRef)
【发布时间】:2012-09-09 16:05:26
【问题描述】:

我正在尝试从我的联系人中获取单个选定个人的地址。

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

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

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

【问题讨论】:

    标签: iphone objective-c ipad contacts abrecord


    【解决方案1】:

    这里你如何获得人的地址属性。

        - (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;
    

    【讨论】:

    • 我试过这个:NSString *street = (__bridge NSString*)ABRecordCopyValue(person, kABPersonAddressStreetKey); 并且它使应用程序崩溃。另外,我收到一条警告:Incompatible pointer to integer conversion passing 'const CFStringRef' (aka 'const struct __CFString *const') to parameter of type 'ABPropertyID' (aka 'int'); 最后,如果一个联系人有多个地址,我应该如何获得这样的多个地址?
    • 使用 int then 代替 NSString。
    猜你喜欢
    • 2017-03-28
    • 1970-01-01
    • 2012-11-26
    • 2017-01-01
    • 1970-01-01
    • 2013-12-16
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    相关资源
    最近更新 更多