How to get email from selected ABPerson in ABPeoplePickerView
I need to access selected person's e-mail from my Cocoa application. I've placed ABPeoplePickerView onto main window and got a list of selected persons via [peoplePicker selectedRecords]
. How do I ac开发者_Go百科cess E-mail field of ABPerson
object?
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
NSString *email = nil;
ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
if(emails){
email = (NSString *) ABMultiValueCopyValueAtIndex(emails,0);
[email autorelease];
}
[self dismissModalViewControllerAnimated:YES];
emaillabel.text = email;
return YES;
}
I assume your ABPerson
object is referenced by person
:
ABRecordCopyValue( ( ABRecordRef ) person, kABEmailProperty );
精彩评论