1

Showing a person picker with ABPeoplePickerNavigationController, I can get the address of the selected person in a dictionary with this:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    if (property == kABPersonAddressProperty) {
        ABMultiValueRef addressMultiValue = ABRecordCopyValue(person, kABPersonAddressProperty);    

        NSDictionary *address = (NSDictionary *)CFBridgingRelease(ABMultiValueCopyValueAtIndex(addressMultiValue, ABMultiValueGetIndexForIdentifier(addressMultiValue, identifier)));

    }

    [self dismissModalViewControllerAnimated:YES];

    return NO;
}

Depending on the country, the convention on how to format this address is not the same.
Is there a way to get the string of the address as displayed by the picker (similar to what Contacts.app shows)?

Guillaume
  • 21,685
  • 6
  • 63
  • 95

1 Answers1

2

I'm not sure how to dynamically create a set of editable address fields as you see in Contacts.app, but there is a utility function in AddressBookUI that allows you to format an address dictionary into a region-specific address string: ABCreateStringWithAddressDictionary. This function relies on the country code value being set correctly; it's unspecified what happens if this value is missing.

warrenm
  • 31,094
  • 6
  • 92
  • 116
  • Great, that is what I was looking for. I do not understand why this is in AddressBookUI, and probably why I did overlook it. – Guillaume Jul 09 '12 at 17:27