Remove a record from address book.
ABAddressBookRef addressbook = ABAddressBookCreate();
ABAddressBookRemoveRecord(addressbook, record, nil);
ABAddressBookSave(addressbook, nil);
CFRelease(addressbook);
----------------------------------------------------------------------------------------
Remove record(s) from address book with specific name.
ABAddressBookRef addressbook = ABAddressBookCreate();
CFStringRef nameRef = (CFStringRef)[NSString stringWithFormat:@"%@ %@", @"Davis", @"Scott"];
CFArrayRef AllRecords_ = ABAddressBookCopyPeopleWithName(addressbook, nameRef);
if (AllRecords_ != NULL)
{
int count = CFArrayGetCount(AllRecords_);
for (int i = 0; i < count; ++i)
{
ABRecordRef contact = CFArrayGetValueAtIndex(AllRecords_, i);
ABAddressBookRemoveRecord(addressbook, contact, nil);
}
}
ABAddressBookSave(addressbook, nil);
CFRelease(addressbook);
No comments:
Post a Comment