在我的一个应用程序中,我使用了 dispatch_queue,在其中我声明了一个dispatch_asyc
用于检查地址簿的队列。现在,当编译器到达 return 语句时,它会导致应用程序崩溃。下面是我的源代码。
dispatch_queue_t queue = dispatch_queue_create("abc", NULL);
dispatch_async(queue, ^{
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
// First time access has been granted...
// All good.
completionBlock?completionBlock(YES):nil;
dispatch_async(queue, ^{
if (addressBookRef) {
CFRelease(addressBookRef);
};
});
return;
});