开发者

Remove a group from Addressbook

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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜