Skip to content

Commit

Permalink
UI stuff should be done on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpixel committed Jan 28, 2017
1 parent d02d694 commit 0386984
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions yalu102/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ - (bool) alreadyJailbroken {
- (void) performForJailbrokenState {
// Check if the device is already jailbroken and change the UI accordingly
if ([self alreadyJailbroken]) {
[dope setEnabled:NO];
[dope setTitle:@"already jailbroken" forState:UIControlStateDisabled];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[dope setEnabled:NO];
[dope setTitle:@"already jailbroken" forState:UIControlStateDisabled];
}];
}
}

Expand Down Expand Up @@ -149,17 +151,21 @@ - (IBAction)yolo:(UIButton*)sender {

- (void)doIt {
#if TARGET_IPHONE_SIMULATOR
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Cannot Jailbreak" message:@"You are currently running the app in the iOS Simulator. To jailbreak, run the tool on a real device." preferredStyle:UIAlertControllerStyleAlert];
[alert addAction: [UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Cannot Jailbreak" message:@"You are currently running the app in the iOS Simulator. To jailbreak, run the tool on a real device." preferredStyle:UIAlertControllerStyleAlert];
[alert addAction: [UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alert animated:YES completion:nil];
}];
#else
/*
we out here!
*/
[dope setEnabled:NO];
[dope setTitle:@"jailbreaking" forState:UIControlStateDisabled];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[dope setEnabled:NO];
[dope setTitle:@"jailbreaking" forState:UIControlStateDisabled];
}];

mach_port_t vch = 0;

Expand Down Expand Up @@ -289,7 +295,9 @@ - (void)doIt {
ports[i] = 0;
}
}
[dope setTitle:@"failed, retry" forState:UIControlStateNormal];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[dope setTitle:@"failed, retry" forState:UIControlStateNormal];
}];
return;

foundp:
Expand All @@ -309,7 +317,9 @@ - (void)doIt {
}
}
}
[dope setTitle:@"failed, retry" forState:UIControlStateNormal];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[dope setTitle:@"failed, retry" forState:UIControlStateNormal];
}];
return;

gotclock:;
Expand Down

0 comments on commit 0386984

Please sign in to comment.