我需要从我的Cocoa应用程序访问所选人员的电子邮件。我已将ABPeoplePickerView放置在主窗口上,并通过[peoplePicker selectedRecords]
获得了一个选定人员列表。如何访问ABPerson
对象的电子邮件字段?
答案 0 :(得分:2)
-(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;
}
答案 1 :(得分:0)
我假设您的ABPerson
对象由person
引用:
ABRecordCopyValue( ( ABRecordRef ) person, kABEmailProperty );