I've encountered something that I've never seen. The scenario is as follows. My initial VC has an enroll button that when hit bring up a couple of separate view controllers deal with the enrollment procedure (I ask for user credentials, and if required by the server, I ask for a verification code). When this process is complete, I save a custom object to NSUserDefaults that is needed later. Then the initial VC is shown again.
Basically, I'm making sure I'm in the main thread and that the custom object is saved. If those conditions are met, I then push the main part of the app.
Here is the relevant code, all my logs are displayed in the output window, but the segue does not happen.
- (void)viewDidLoad {
[super viewDidLoad];
self.complete = false;
if([NSThread isMainThread]){
NSLog(@"Main Thread-Yes");
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"CUSTOMOBJECT"]) {
NSLog(@"Will begin pushToAuthenticate");
[self pushAuthenticateController];
}
} else {
NSLog(@"Main Thread-No");
}
}
- (void)pushAuthenticateController{
[self performSegueWithIdentifier:@"pushMainVC" sender:self];
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"pushMainVC"]) {
NSLog(@"PrepareForSegue-pushMainVC");
[segue.destinationViewController.navigationItem setHidesBackButton:YES];
[segue.destinationViewController.navigationItem setTitle:@"MainVC"];
}
}
In storyboard I have a segue that connects the initial VC with the MainVC, the identifier for that segue matches "pushMainVC", and if I close and reopen the app (after enrolling) the segues does occur. The console output for both instances (reloading the initial VC after enrolling and closing and reopening the app) are as follow:
APPNAME[4106:1628238] Main Thread-Yes
APPNAME[4106:1628238] Will begin pushToAuthenticate
APPNAME[4106:1628238] PrepareForSegue-pushMainVC
Any idea why this could happen, any small thing I'm missing, or any help will be greatly appreciated. Thank you so much.