gpt4 book ai didi

cocoa - 如何在 OS X Lion 上获取用户的邮件地址?

转载 作者:行者123 更新时间:2023-12-03 17:29:42 25 4
gpt4 key购买 nike

我从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com