I have create some groups in addressbook in code. I use the code below to remove a specific group. ABAddressBookRemoveRecord() returns YES. but the group is still there! What is wrong with the code?
BOOL res;
CFErrorRef error;
ABAddressBookRef ab = ABAddressBookCreate();
NSArray *groups = (NSArray *) ABAddressBookCopyArrayOfAllGroups(ab);
for (id _group in groups)
{
NSString *currentGroupName = [[NSString alloc] init];
currentGroupName = (NSString*) ABRecordCopyValue(_group, kABGroupNameProperty);
if ([groupName isEqualToString:currentGroupName])
{
[currentGroupName release];
res = ABAddressBookRemoveRecord(ab, _group, &error);
return res;
}
[currentGroupName release];开发者_JAVA百科
}
return NO;
add this ABAddressBookSave(ab, nil);
before return res;
精彩评论