作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 Libraray/Preferences/com.apple.mail.plist 获取用户的邮件地址。它们在 Lion 中不再存在:P 我必须使用脚本桥吗?有什么提示吗?谢谢
最佳答案
我会直接从地址簿中获取它们。无论使用什么电子邮件应用程序,这都应该有效。
// Find 'me' card in address book.
ABPerson* meCard = [[ABAddressBook sharedAddressBook] me];
if( meCard == nil ) {
NSLog( @"Could not find me!" );
return;
}
// Get my email addresses.
ABMultiValue* anEmailList = [meCard valueForProperty:kABEmailProperty];
if( anEmailList == nil ) {
NSLog( @"I have no email!" );
return;
}
// Output them.
for( NSUInteger index = 0; index < [anEmailList count]; index++ ) {
NSString* aLabel = [anEmailList labelAtIndex:index];
NSString* aValue = [anEmailList valueAtIndex:index];
NSLog( @"%@: %@", aLabel, aValue );
}
关于cocoa - 如何在 OS X Lion 上获取用户的邮件地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6794312/
我是一名优秀的程序员,十分优秀!