我正在使用以下代码向地址簿请求权限并将其保存到应用程序的UserDefaults。
if (ABAddressBookRequestAccessWithCompletion != NULL)
{
// we're on iOS 6
ABAddressBookRef addressBookRef = ABAddressBookCreate();
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
accessgranted = granted;
if(accessgranted)
{
[self saveaddressbookpermission:accessgranted];
[NSThread detachNewThreadSelector:@selector(startbgprocess) toTarget:self withObject:nil];
}
});
CFRelease(addressBookRef);
}
else {
// we're on iOS 5 or older
accessgranted = YES;
[self saveaddressbookpermission:accessgranted];
NSLog(@"in iOS 5");
[NSThread detachNewThreadSelector:@selector(startbgprocess) toTarget:self withObject:nil];
}
问题是当我尝试使用设置 - >常规 - >重置 - >重置隐私设置时重置位置&隐私,但如果我尝试从设置 - >隐私 - >更改隐私设置并从那里关闭权限然后我的应用程序崩溃。我该如何处理这种情况。如果我无法找到任何其他相关信息,请通知我。