I have the following workflow defined within my iPhone project storyboard:
- Login view controller is set as root view controller in a storyboard.
- Login has a separate workflow for login and setting up account.
- Both workflows end up modally presenting tab bar with the main app content
- For subsequent app launches, I programmatically determine the correct controller to instantiate in
appDidFinishLaunching:
- For subsequent app use the tab bar with main content is the root view controller (programmatically set)
Now I would like to implement a "logout" process - a button wipes all the user data and brings the user back to the original "login/set up account" screen.
I'm running into an issue where due to multiple states of the application I need to have multiple paths to return to the home screen. For example:
UIViewController* parent = self.presentingViewController;
UIViewController* grandparent = self.presentingViewController;
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
DLog(@"first dismiss");
DLog(@"%@",parent);
DLog(@"%@",grandparent);
[parent dismissViewControllerAnimated:YES completion:^{
DLog(@"second dismiss");
[grandparent.navigationController popToRootViewControllerAnimated:YES];
}];
}];
How would I go about implementing the login/logout logic defined above?
Is there a correct way to completely collapse the view hierarchy that is currently that is currently on screen and replace it with another one?
I'm thinking of this one:
[self.window setRootViewController:tabBarViewController];
But am not sure if this will properly unload all resources used by the old rootViewController stack that I'm detaching.