Index: iOS/ShowDetailsController.m ================================================================== --- iOS/ShowDetailsController.m +++ iOS/ShowDetailsController.m @@ -161,35 +161,35 @@ }]; } - (void)_generateWithCallback: (void (^)(NSMutableString *))block { - UIStoryboard *mainStoryboard = - [UIStoryboard storyboardWithName: @"Main" - bundle: nil]; - UIViewController *activityController = [mainStoryboard + id generator; + char *passphrase; + UIStoryboard *mainStoryboard; + UIViewController *activityController; + + if (_legacy) + generator = [LegacyPasswordGenerator generator]; + else + generator = [NewPasswordGenerator generator]; + + generator.site = _name; + generator.length = _length; + + passphrase = of_strdup([self.passphraseField.text UTF8String]); + generator.passphrase = passphrase; + + mainStoryboard = [UIStoryboard storyboardWithName: @"Main" + bundle: nil]; + activityController = [mainStoryboard instantiateViewControllerWithIdentifier: @"activityIndicator"]; [self.navigationController.view addSubview: activityController.view]; dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ { - id generator; - char *passphrase; - - if (_legacy) - generator = [LegacyPasswordGenerator generator]; - else - generator = [NewPasswordGenerator generator]; - - generator.site = _name; - generator.length = _length; - - passphrase = of_strdup([self.passphraseField.text UTF8String]); @try { - self.passphraseField.text = @""; - generator.passphrase = passphrase; - [generator derivePassword]; } @finally { of_explicit_memset(passphrase, 0, strlen(passphrase)); free(passphrase); } @@ -197,12 +197,14 @@ NSMutableString *password = [NSMutableString stringWithUTF8String: (char *)generator.output]; of_explicit_memset(generator.output, 0, strlen((char *)generator.output)); - activityController.view.hidden = YES; - block(password); + dispatch_sync(dispatch_get_main_queue(), ^ { + activityController.view.hidden = YES; + block(password); + }); }); } - (IBAction)remove: (id)sender {