Created
August 1, 2012 20:42
-
-
Save stevemoser/3230545 to your computer and use it in GitHub Desktop.
GCD FAIL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)loadA | |
{ | |
} | |
- (void)loadA | |
{ | |
[[self aDataSource] loadAWithOnLoad:^(NSArray *newObjects) { | |
NSLog(@"WAIT 1"); | |
} onError:^(NSError *error) { | |
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; | |
[alert show]; | |
}]; | |
} | |
- (void)loadB...loadC.... | |
- (void)reload | |
{ | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_group_t group = dispatch_group_create(); | |
dispatch_group_async(group, queue, ^{ | |
[self loadA]; | |
}); | |
dispatch_group_async(group, queue, ^{ | |
[self loadB]; | |
}); | |
dispatch_group_async(group, queue, ^{ | |
[self loadC]; | |
}); | |
dispatch_group_notify(group, queue, ^{ | |
NSLog(@"WAIT FINAL"); | |
}); | |
dispatch_release(group); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment