Question

I can get home (from kABHomeLabel), work (from kABWorkLabel), other (from kABOtherLabel) mail addresses.

But I can't figure out how to get iCloud mail address from Address Book.

EDIT:

Complete answer (thanks to 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);
Was it helpful?

Solution

Following the method given in this answer - How to get Custom label and value of the Email in ABAddressBook - should allow you to get the labels for the email fields, including the iCloud label.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top