How I do fire a method when I am confident both block codes have returned? Like so…
// Retrieve Messages Array from Parse
[ParseManager retrieveAllMessagesForShredderUser:(ShredderUser *)[PFUser currentUser] withCompletionBlock:^(BOOL success, NSError *error, NSArray *objects){
self.messagesArray = objects;
}];
// Retrieve MessagesPermissions Array from Parse
[ParseManager retrieveAllMessagePermissionsForShredderUser:(ShredderUser *)[PFUser currentUser] withCompletionBlock:^(BOOL success, NSError *error, NSArray *objects){
self.messagePermissionsArray = objects;
}];
-(void)methodToRunWhenBothBlocksHaveReturned{
}
If you can guarantee that the blocks will be executed on the same thread (i.e., the UI thread), then the alternative is simple, using a
__blockvariable.If you don’t have the same-thread guarantee, you can use a lock to make sure that the increment of the variable (and the comparison to 2) will be atomic.