Adding phonenumbers to ABPerson

Adding phonenumbers to ABPerson

Also, email addresses are similar…

[sourcecode lang=”cpp”]

// Where email is the string and kABOtherLabel cd also be kABHomeLabel or kABWorkLabel.
ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABPersonEmailProperty);
ABMultiValueAddValueAndLabel(emailMultiValue, email, kABOtherLabel, NULL);
ABRecordSetValue(person, kABPersonEmailProperty, emailMultiValue, nil);

[/sourcecode]

Update: Here’s code to fetch phone numbers…

[sourcecode lang=”cpp”]

ABMutableMultiValueRef phoneNumberMultiValue =  ABRecordCopyValue(record, kABPersonPhoneProperty);  
for (CFIndex i = 0; i < ABMultiValueGetCount(phoneNumberMultiValue); i++) { CFStringRef label = ABMultiValueCopyLabelAtIndex(phoneNumberMultiValue, i); CFStringRef phoneNum = ABMultiValueCopyValueAtIndex(phoneNumberMultiValue, i); } [/sourcecode]