从地址簿获取iPhone iCloud邮件地址

时间:2014-03-15 23:40:49

标签: ios iphone objective-c icloud abaddressbook

我可以获得home(来自kABHomeLabel),work(来自kABWorkLabel),other(来自kABOtherLabel)邮件地址。

但我无法弄清楚如何从地址簿中获取iCloud邮件地址。

修改

完整答案(感谢Paulw11):

ABMultiValueRef emailsRef = ABRecordCopyValue(person, kABPersonEmailProperty);
for (int i=0; i<ABMultiValueGetCount(emailsRef); i++) {
    CFStringRef currentEmailLabel = ABMultiValueCopyLabelAtIndex(emailsRef, i);
    CFStringRef currentEmailValue = ABMultiValueCopyValueAtIndex(emailsRef, i);
    NSString *emailLabel = (__bridge NSString *)ABAddressBookCopyLocalizedLabel(currentEmailLabel);

    [contactInfoDict setObject:(__bridge NSString *)currentEmailValue
                        forKey:[NSString stringWithFormat:@"%@Email",emailLabel] ];

    CFRelease(currentEmailLabel);
    CFRelease(currentEmailValue);
    emailLabel = nil;
}
CFRelease(emailsRef);

1 个答案:

答案 0 :(得分:0)

按照此回答中给出的方法 - How to get Custom label and value of the Email in ABAddressBook - 应该允许您获取电子邮件字段的标签,包括iCloud标签。