In one of my apps I am using dispatch_queue and inside this I declared a dispatch_asyc
queue for checking the address book. Now when compiler comes to the return statement, it causes app to crash. Below is my source code.
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;
});