Reputation: 81
I want to get contact no on label when user tap on phone no . But my code taking first phone no automatically. I am using this
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person
{
[self getPeopleContactProperties:person:0];
}
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
[self getPeopleContactProperties:person:identifier];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker;
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)getPeopleContactProperties :(ABRecordRef)person :(ABMultiValueIdentifier)identifier
{
NSString *email;
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonPhoneProperty);
if (emails) {
CFIndex index;
if (identifier == 0) {
index = 0;
} else {
index = ABMultiValueGetIndexForIdentifier(emails, identifier);
}
email = (__bridge NSString *) ABMultiValueCopyValueAtIndex(emails,index);
}
resultlabel.text =email;
}
Upvotes: 1
Views: 73
Reputation: 81
if ([peoplePicker respondsToSelector:@selector(setPredicateForSelectionOfPerson:)])
{
peoplePicker.predicateForSelectionOfPerson = [NSPredicate predicateWithFormat:@"%K.@count > 1", ABPersonPhoneNumbersProperty];
}
Upvotes: 1