ABAddressBookSave失败,没有错误

时间:2018-04-15 05:50:15

标签: ios objective-c iphone abaddressbook

我正在尝试使用以下代码在本机中创建联系人组。我正在尝试的方案是:在本机邮件中添加任何Outlook帐户然后启用联系人同步,这将创建一个联系人组。在此之后如果我试图从我的应用程序创建一个组,那么它失败了..

ABAddressBookRef addressBook = ABAddressBookCreate();
    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (granted) {
                CFErrorRef error = NULL;
                ABRecordRef worxMailGroup = ABGroupCreate();
                BOOL success = ABRecordSetValue(worxMailGroup,kABGroupNameProperty,(__bridge CFTypeRef) @"TestGroup2",&error);
                if (success) {
                    bool bStatus = ABAddressBookAddRecord(addressBook, worxMailGroup, &error);
                    if (bStatus) {
                        bStatus = ABAddressBookSave(addressBook, &error);
                        // bStatus is false and error also nil ..
                    }
                }
            }
        });
    });

由于

0 个答案:

没有答案