In my AppDelegate I check if there is already a user logged in.
if (userExists) {
// Set my main view as the root view controller.
UINavigationController *navController = [[UINavigationController alloc] init];
MainViewController *mainVC = [[MainViewController alloc] init];
[navController setRootViewController:mainVC animated:YES];
[self.window setRootViewController:navController];
}
If there is no existing user I present a login screen.
Now, once the user has logged in I have to continue the flow, showing the MainViewController
.
I am currently doing the following, in a block that gets called when the user is successfully authenticated:
UINavigationController *navController = [[UINavigationController alloc] init];
MainViewController *mainVC = [[MainViewController alloc] init];
[navController setRootViewController:wordViewController animated:YES];
UIApplication *application = [UIApplication sharedApplication];
[application.windows.firstObject setRootViewController:navController];
Is this a good way to go? Since this is a frequently repeated pattern throughout iOS apps, what is the most common, sensible way of doing this?