iphoneobjective-cipadcontactsabrecord

Get Multiple Addresses From Contacts? (ABRecordRef)


I am trying to get the address of a single selected individual from my contacts.

I am using ABPeoplePickerNavigationController and this delegate method to get data like emails and names upon selection of a person:

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

But how can I get the address of a person (or multiple addresses of a single person should they have more than one)? I need to get each address individually and broken into parts, like address line 1, 2, city, state, zip code, country.


Solution

  • here how you get the address property of the person.

        - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)
              peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 
              property:(ABPropertyID)property
              identifier:(ABMultiValueIdentifier)identifier{
    
               NSString *string = (NSString*)ABRecordCopyValue(person, AddressPropertyHere);
    }
    

    list of address property constants:

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