Tôi đã có cùng một câu hỏi này. Tôi không thể tìm thấy câu trả lời nên tôi chỉ thử phương pháp đoán và kiểm tra. Các mã sau đây dường như làm việc:
CFErrorRef error = NULL;
ABAddressBookRef iPhoneAddressBook = ABAddressBookCreate();
ABRecordRef newPerson = ABPersonCreate();
ABRecordSetValue(newPerson, kABPersonFirstNameProperty, @"Jane", &error);
ABRecordSetValue(newPerson, kABPersonLastNameProperty, @"Smith", &error);
const CFStringRef customLabel = CFSTR("mylabel");
//phone
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiPhone, @"1-444-444-444", kABPersonPhoneMainLabel, NULL);
ABMultiValueAddValueAndLabel(multiPhone, @"1-333-333-333", kABPersonPhoneMobileLabel, NULL);
ABMultiValueAddValueAndLabel(multiPhone, @"1-666-666-666", kABOtherLabel, NULL);
ABMultiValueAddValueAndLabel(multiPhone, @"1-555-555-555", customLabel, NULL);
ABRecordSetValue(newPerson, kABPersonPhoneProperty, multiPhone,nil);
CFRelease(multiPhone);
ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error);
ABAddressBookSave(iPhoneAddressBook, &error);
if (error != NULL)
{
NSLog(@"Error!");
}
Nếu bạn đánh dấu vào sổ địa chỉ, bạn sẽ thấy một số điện thoại với một nhãn tùy chỉnh: mylabel
Nhờ: this post
Và để: this blog
Nó hoạt động tốt với tôi, cảm ơn rất nhiều! – Will