Here is a code snippet that a person creates, adds 2 phone contacts, and then shows how to get to the label and value for the phone property:
ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueIdentifier multivalueIdentifier; ABMultiValueAddValueAndLabel(multi, @"(555) 555-1234", kABPersonPhoneMobileLabel, &multivalueIdentifier); ABMultiValueAddValueAndLabel(multi, @"(555) 555-2345", kABPersonPhoneMainLabel, &multivalueIdentifier); ABRecordRef aRecord = ABPersonCreate(); CFErrorRef anError = NULL; ABRecordSetValue(aRecord, kABPersonPhoneProperty, multi, &anError); CFRelease(multi); multi = ABRecordCopyValue(aRecord, kABPersonPhoneProperty); for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++) { CFStringRef phoneNumber, phoneNumberLabel; phoneNumberLabel = ABMultiValueCopyLabelAtIndex(multi, i); phoneNumber = ABMultiValueCopyValueAtIndex(multi, i); NSLog(@"%@ %@", (NSString *) phoneNumberLabel, (NSString *) phoneNumber); CFRelease(phoneNumberLabel); CFRelease(phoneNumber); } CFRelease(aRecord); CFRelease(multi);
In code, it iterates over all multi-valued values ββand extracts the label and number as they are used, using ABMultiValueCopyLabelAtIndex and ABMultiValueCopyValueAtIndex respectively.
source share