Create alert dialogs on the main thread

This commit is contained in:
Cameron Gutman
2015-06-23 21:46:58 -07:00
parent 005a678089
commit f8b5b16109
@@ -102,24 +102,32 @@
} }
- (void) stageFailed:(char*)stageName withError:(long)errorCode { - (void) stageFailed:(char*)stageName withError:(long)errorCode {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Connection Failed" Log(LOG_I, @"Stage %s failed: %ld", stageName, errorCode);
message:[NSString stringWithFormat:@"%s failed with error %ld",
stageName, errorCode] dispatch_async(dispatch_get_main_queue(), ^{
preferredStyle:UIAlertControllerStyleAlert]; UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Connection Failed"
[alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){ message:[NSString stringWithFormat:@"%s failed with error %ld",
[self returnToMainFrame]; stageName, errorCode]
}]]; preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil]; [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
[self returnToMainFrame];
}]];
[self presentViewController:alert animated:YES completion:nil];
});
} }
- (void) launchFailed:(NSString*)message { - (void) launchFailed:(NSString*)message {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Connection Failed" Log(LOG_I, @"Launch failed: %@", message);
message:message
preferredStyle:UIAlertControllerStyleAlert]; dispatch_async(dispatch_get_main_queue(), ^{
[alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){ UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Connection Failed"
[self returnToMainFrame]; message:message
}]]; preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil]; [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
[self returnToMainFrame];
}]];
[self presentViewController:alert animated:YES completion:nil];
});
} }
- (void) displayMessage:(char*)message { - (void) displayMessage:(char*)message {