I have method which is clear the adress book in the device. the method is below.
-(void) clearAdressBook
{
ABAddressBookRef addrBook=ABAddressBookCreate();
CFArrayRef groups = ABAddressBookCopyArrayOfAllGroups(addrBook);
if(groups)
{
CFIndex numGroups = CFArrayGetCount(groups);
for(CFIndex idx=0; idx<numGroups; ++idx)
{
ABRecordRef groupItem = CFArrayGetValueAtIndex(groups, idx);
CFArrayRef people=
ABGroupCopyArrayOfAllMembers(groupItem);
if(people)
{
CFIndex peopleCount=CFArrayGetCount(people);
for(CFIndex ind=0;ind<peopleCount;++ind)
{
ABRecordRef person=CFArrayGetValueAtIndex(people, ind);
ABAddressBookRemoveRecord(addrBook, person, nil);
ABAddressBookSave(addrBook, NULL);
CFRelease(person);
}
CFRelease(people);//CRASH
}
}
}
CFRelease(groups);
}
when I'm releasing CFArrayRef application crashes, what is wrong here? As i know i have to release all objected returned from CF methods which names contains copy or create right ?