The simplest approach with more than lock is to use
dispatch_group_t confirmGroup = dispatch_group_create(); // 1
if (requestContacts) {
dispatch_group_enter(confirmGroup); // 2
[Extractor requestAccessAddressBook:^(BOOL isComplete) {
if (isComplete) {
dispatch_group_leave(confirmGroup); //2
}
}];
}
if (requestEvent) {
dispatch_group_enter(confirmGroup); // 3
[Extractor requestAccessEvents:^(BOOL isComplete) {
if (isComplete) {
dispatch_group_leave(confirmGroup); // 3
}
}];
}
if (requestPhoto) {
dispatch_group_enter(confirmGroup); // 4
[Extractor requestAccessPhotos:^(BOOL isComplete) {
if (isComplete) {
dispatch_group_leave(confirmGroup); //4
}
}];
}
NSLog(@"dispatch_group_wait confirmations");
dispatch_group_wait(confirmGroup, DISPATCH_TIME_FOREVER); // 5