I am working on a piece of code where when the users presses the submit button, he is asked to update his/her password before he is able to go to the app screen. SO when you press the button, the 'Login' procedure gets executed, and the user is authenticated into the app, and in the completion block we show the 'resetpassword' view controller. However, push does not seem to work. I do print the navigationController object before and within the block, and it is not nil.
NSLog(@"%@", [self.navigationController description]);
__weak __typeof(self) weakSelf = self;
[[AppDelegate sharedDelegate] login:self.userIdentifierTextField.text
password:self.passwordTextField.text
persistence:NSURLCredentialPersistencePermanent
completion:^(BOOL success, NSError *error) {
SignInViewController *innerWeak = weakSelf;
if ([[Features sharedFeatures] allowsAdminMandatedPasswordReset]) {
//User needs to add new password
ResetPasswordViewController *resetViewController = [[ResetPasswordViewController alloc] initWithNibName:[ResetPasswordViewController nibName] bundle:nil];
NSLog(@"%@", [self.navigationController description]);
if (innerWeak.navigationController != nil) {
[innerWeak.navigationController pushViewController:resetViewController animated:YES];
}
}
[MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
mainWindow.userInteractionEnabled = YES;
}];
Here, when i compare the two nslogs on the navigationController object, they are the same. Even presenting the resetViewController modally is working in the completion block, but somehow the push does not work. I have spent a lot of time trying to figure out, and i am totally confused on what's going on.
Update : using the following works for me. But i would still like to root cause the issue with weakSelf.navigationController
[[AppDelegate sharedDelegate].navigationController pushViewController:resetViewController animated:YES];