Skip to content

Instantly share code, notes, and snippets.

@userow
Created October 13, 2019 13:32
Show Gist options
  • Save userow/54735a3bd7fd29152b2a7333879e904f to your computer and use it in GitHub Desktop.
Save userow/54735a3bd7fd29152b2a7333879e904f to your computer and use it in GitHub Desktop.
- (void)loginComplete {
dispatch_group_t group = dispatch_group_create();
dispatch_group_enter(group);
dispatch_group_enter(group);
[self.languageRouter receiveWithSuccess:^(NSDictionary *object) {
[self createOrUpdateLanguagesWithJSON:object completion:^{
dispatch_group_leave(group);
}];
} failure:^(NSString *message, NSInteger code, ErrorType type) {
self.successfullDownload = NO;
[self.hud hideAnimated:YES];
[self showAlertWithTitle:@"" message:message];
dispatch_group_leave(group);
}];
[self.languageRouter receiveCountriesWithSuccess:^(NSDictionary *object) {
[self createOrUpdateCouintriesWithJSON:object completion:^{
dispatch_group_leave(group);
}];
} failure:^(NSString *message, NSInteger code, ErrorType type) {
self.successfullDownload = NO;
[self.hud hideAnimated:YES];
[self showAlertWithTitle:@"" message:message];
dispatch_group_leave(group);
}];
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
if (self.successfullDownload) {
[self languageCountryDownloadCompleted];
} else {
[Profile clear];
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment