iPhone Objective-C: Best way to handle logout user A -> login user B?
I have an application that uses OAuth whose logic is something like this: If there is a request token for the user that is valid stored, loads a UITabBarController with four views. Else, brings开发者_如何学JAVA the user to the login screen.
I realized today that if I am logged into my app, log out, and switch to another user, the data from the first user is displayed until I hit refresh. Also, the tab that was last viewed by the previous user is displayed (which is pretty strange for an application user's point of view).
I thought about removing the TabBarController and creating a new one, but I realized I was not sure how to do that, considering that I set everything up through Interface Builder. (Also, I'm not even sure if that is the best way.)
What is a good way for handling log out of A -> log into B? Also, if you need more information, I'll be very happy to elaborate.
Thank you!
I do it as follows
Login
- Load and display the login screen
- Load the root view controller in background
- Insert the root view controller behind the login screen
- Remove/release the login screen after successful login
Logout
- Load the login screen and place it on bottom of the view stack (behind the root view)
- Remove/release the root view controller (login becomes visible)
- ... start over at 2) in Login
If you store user specific data in the documents directory, store it in subdirectories with the user name or id as directory name. One directory for each user.
精彩评论