How to get email address for iPhone address book as NSStrings?

I know that there can be several values ​​for email, but I'm not sure how to view them.

I can get a person right.

ABRecordRef person = // getting a person;
NSString* emails = (NSString *)ABRecordCopyValue(person, kABPersonEmailProperty);

... what's next? If I try to print the variable emails, I get:

Emails: <NSCFType: 0x4018d40>
+5
source share
3 answers

This is because letters should not be a string, but an array. People can have many letters!

ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef email = ABMultiValueCopyValueAtIndex(emails, <INDEX>);
NSLog( (NSString *) email);

Below are some docs on what you can do with MultiValueLists

+16
source

- ABMultiValue ( , - kABMultiStringProperty). . " " . . Objective-C .

, , AB Create Rule. , , "" .

+4

iOS 9 ABFramework :

CNContact:

CNContact * yourContact = //...

for (CNLabeledValue* emailLabeledValue in yourContact.emailAddresses){
    NSLog(@"%@",[emailLabeledValue value]);
}
+1

All Articles