#import <AddressBookUI/AddressBookUI.h>
#import <AddressBook/AddressBook.h>
ABPeoplePickerNavigationControllerDelegate
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:NULL];
#pragma mark - ABPeoplePickerNavigationControllerDelegate
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[peoplePicker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, property);
NSString *phone = nil;
int index = ABMultiValueGetIndexForIdentifier(phoneNumbers,identifier);
if ((ABMultiValueGetCount(phoneNumbers) > 0)) {
phone = (NSString *)ABMultiValueCopyValueAtIndex(phoneNumbers, index);
} else {
phone = @"[None]";
}
CFRelease(phoneNumbers);
userNameF.text = phone;
[peoplePicker dismissViewControllerAnimated:YES completion:NULL];
}