Si l'utilisateur a plusieurs adresses définies - travail, domicile, etc., vous devrez utiliser l'attribut d'identifiant pour les distinguer. Ce que j'ai trouvé, tiré de messages similaires sur les adresses e-mail, est :
#pragma mark - ABPeoplePickerNavigationControllerDelegate
- (IBAction)chooseContact:(id)sender
{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:nil];
// [self dismissViewControllerAnimated:YES completion:nil];
}
- (void) peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
return YES;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
if (property == kABPersonAddressProperty)
{
ABMultiValueRef addresses = ABRecordCopyValue(person, property);
CFIndex addressIndex = ABMultiValueGetIndexForIdentifier(addresses, identifier);
CFDictionaryRef address = ABMultiValueCopyValueAtIndex(addresses, addressIndex);
// créer une chaîne d'adresse à rechercher
NSString *street = (NSString*) CFDictionaryGetValue(address, kABPersonAddressStreetKey);
NSString *city = (NSString*) CFDictionaryGetValue(address, kABPersonAddressCityKey);
NSString *state = (NSString*) CFDictionaryGetValue(address, kABPersonAddressStateKey);
NSString *postal = (NSString*) CFDictionaryGetValue(address, kABPersonAddressZIPKey);
NSString *country = (NSString*) CFDictionaryGetValue(address, kABPersonAddressCountryKey);
CFRelease(address);
CFRelease(addresses);
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
return YES;
}
.