在 Cocoa 中获取用户的默认电子邮件地址 [英] Getting user's default email address in Cocoa

查看:29
本文介绍了在 Cocoa 中获取用户的默认电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取用户的默认电子邮件地址?我需要为我的崩溃报告对话框获取它,这样用户就不必手动填写它.

How do I obtain the user's default email address? I need to obtain it for my crash reporter dialog, so the user won't have to fill it out manually.

推荐答案

没关系,我明白了.首先,我只需要将 AddressBook.framework 添加到我的链接框架中.然后,这是所需的代码:

Never mind, I got it. First, I just have to add AddressBook.framework into my Linked Frameworks. Then, this is the code required:

#import <AddressBook/AddressBook.h>

NSString *theEmailAddressWeWantToObtain = @"";
ABPerson *aPerson = [[ABAddressBook sharedAddressBook] me];
ABMultiValue *emails = [aPerson valueForProperty:kABEmailProperty];
if([emails count] > 0)
  theEmailAddressWeWantToObtain = [emails valueAtIndex:0];

这篇关于在 Cocoa 中获取用户的默认电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆