开发者

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

  1. Load and display the login screen
  2. Load the root view controller in background
  3. Insert the root view controller behind the login screen
  4. Remove/release the login screen after successful login

Logout

  1. Load the login screen and place it on bottom of the view stack (behind the root view)
  2. Remove/release the root view controller (login becomes visible)
  3. ... 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜