开发者

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 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜