adding a new number to existing ABRecord in ABAddressBook - iPhone

前端 未结 1 1288
一整个雨季
一整个雨季 2021-01-06 04:40

I am trying to update the content of an existing contact in the addressbook through my application but without the need for a UI. The scenario is like this:

1 The us

相关标签:
1条回答
  • 2021-01-06 05:24

    After further look this morning at the APIs i managed to find the solution. Here you go:

    // contactId is the ID of the person i need to add a new number to his contacts
    // got the id through : ABRecordGetRecordID( ABRecordRef )
    ABRecordRef person = ABAddressBookGetPersonWithRecordID(lAddressBook, contactID);
    ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutableCopy(lPhoneNumbers);
    ABMultiValueAddValueAndLabel(multiPhone, number, (CFStringRef)@"Duplicate", NULL);      
    //add the number to the contact
    ABRecordSetValue(person, kABPersonPhoneProperty, multiPhone,nil);
    ABAddressBookSave(lAddressBook, &error);
    
    0 讨论(0)
提交回复
热议问题