Convert kABemailProperty to NSString

292 views Asked by At

In my address book app, when I fetch email id for the contact, I et something like this:

ABMultiValueRef 0x2994e0 with 1 value(s)
0: null (0x3f5655e0) - [email protected] (0x2994b0)

How to get string value i.e. only

 [email protected]

from above result?

Thanks

1

There are 1 answers

0
melsam On BEST ANSWER
// This is what you have currently (i.e. the multivalues)
ABMultiValueRef emailValues = ABRecordCopyValue(person, kABPersonEmailProperty);

// This is how you extract the first item from the multivalues:
CFStringRef cfEmailAddress = ABMultiValueCopyValueAtIndex(emailValues, 0);

// This is how you convert it to an NSString.
NSString *emailAddress = CFBridgingRelease(cfEmailAddress);