如何从 ABPeoplePickerView 中选定的 ABPerson 获取电子邮件

发布于 2024-10-19 04:04:37 字数 162 浏览 5 评论 0原文

我需要从我的 Cocoa 应用程序访问所选人员的电子邮件。我已将 ABPeoplePickerView 放置到主窗口上,并通过 [peoplePicker selectedRecords] 获取所选人员的列表。如何访问 ABPerson 对象的电子邮件字段?

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 access E-mail field of ABPerson object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

踏月而来 2024-10-26 04:04:37
-(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;
}
-(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;
}
骄兵必败 2024-10-26 04:04:37

我假设您的 ABPerson 对象被 person 引用:

ABRecordCopyValue( ( ABRecordRef ) person, kABEmailProperty );

I assume your ABPerson object is referenced by person:

ABRecordCopyValue( ( ABRecordRef ) person, kABEmailProperty );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文