I am trying to get the email value of an address book contact.
I need to capture which email the user click and I can figure out how to get the syntax right.
I used an example which picked the first email available, but I am now trying to switch it to the email that the user selects. I started writing //NSString* email = ABRecordCopyValue(property, );
or how to get the index value of what the user selected. If I had the index value of the email selected, I could reuse the code that I had commented out.
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);
self.userName.text = name;
self.myMessage.recpipientName = name;
//NSString* email = ABRecordCopyValue(property)
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
// if (ABMultiValueGetCount(emails) > 0) {
// email = (__bridge_transfer NSString*)
// ABMultiValueCopyValueAtIndex(emails, 0);
// } else {
// email = @"[None]";
// }
self.userEmail.text = email;
self.myMessage.recipientEmail = email;
CFRelease(emails);
return NO;
}