Search code examples
iphoneobjective-ciosaddressbook

How to get street address from ABPeoplePickerNavigationController


I need a contact's street address. I know how to get the single value properties, but the street address is a multivalue property. Apple's documentation shows how to set it, but not retrieve it. Any help?

PS: this does not work:

ABRecordCopyValue(person, kABPersonAddressStreetKey);

Solution

  • I just figured it out:

    ABMultiValueRef st = ABRecordCopyValue(person, kABPersonAddressProperty);
    if (ABMultiValueGetCount(st) > 0) {
        CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(st, 0);
        self.street.text = CFDictionaryGetValue(dict, kABPersonAddressStreetKey);
    }