Search code examples
iosobjective-ccocoa-touchabaddressbook

Changing the name of a group (ABGroup) in iOS address book


I would like to add the ability to change the name of a group in the address book. However I can't seem to find an existing method to do this.

Does anyone know if such a method exists? Or is my only option to copy the members of the group, add them to a new group with the new name, and delete the old group?


Solution

  • You can use the function

    bool ABRecordSetValue (ABRecordRef record,ABPropertyID property,CFTypeRef value,CFErrorRef *error);  
    

    record is the reference to the group record in the address book
    property is the kABGroupNameProperty property that represents the group name
    value is the new group name

    Afterwards you have of course to save the address book with

    OK = ABAddressBookSave(addressBookRef, &error);