11.6. Inserting a Group Entry into the Address Book
You want to categorize your contacts into groups.
Bear in mind that, as mentioned before, Core Foundation memory management is more complex than what Xcode’s static analyzer could process. Therefore, attempting to use the LLVM compiler to compile Core Foundation code with static analysis turned on might give you a lot of warnings. You can ignore these and test the code with Instruments to make sure your code does not leak, but I encourage you to familiarize yourself with memory management in Core Foundation by reading Apple’s “Memory Management Programming Guide for Core Foundation” document, as mentioned in the previous section.
After retrieving the reference to the address book database, you
can call the
to create a new group entry. However, you must perform a few
more operations before you can insert this group into
the address book operation. The first thing you have to do is set the
name of this group using the
ABRecordSetValue function with the
kABGroupNameProperty property, as shown in the
After the name of the group is set, add it to the address book
database just like you add a new person’s entry—using the
ABAddressBookAddRecord function. For more
information about adding a new person’s entry to the address book
database, please read Recipe 11.5.
Inserting a new group with a name that already exists in the address book database ...