Reputation: 655
Recently, I am work on a new app that link up with some social network, for example, twitter, facebook, linkedIn... Actually, I have done a similar app before, but this time I want to ask for more opinions on managing them.
Here is my practice.
Senario:
Questions:
How to let the user login?
a) just setRootController:TabBar controller
, and add a login View overlaying the tabBarView
(problem: some of the controllers of tabBarCon
may need some user information to init or to display the content. This method may cost lots of work to reload the controllers)
b) addSubview:loginView
to window. after login, create the tabBarController
and addSubview:tabBarCon.view
(I wonder if it is necessary to setRootController
in application:didFinishLaunchingWithOptions
, because I receive warning if i didn't)
How to store the user info, like facebook id or etc.
a) directly save it to userdefault
b) use a user model to record these stuff and save the user object to userdefault
It's maybe a stupid question. I am seeking for more opinions in this situation. (Question 1 is more important :) )
Other suggestions are welcome
Upvotes: 0
Views: 172
Reputation: 10633
To question 1.
It should be a view controller. How do I know? Because there is logic involved, web calls, data models etc. Follow the MVC paradigm as close as possible from the start. You should not have to reload the view controllers when you login. Normally there will be some event (notification, delegate, block) that will notify your view controllers and they can layout the view fresh. This is normal activity. Design your view controllers to have "logged in" and "logged out" interfaces - almost always.
To question 2.
If you use core data for something else and have it already configured, use it. You can just add attributes to your data model where required. Otherwise if you want to do it quickly and you only handle one user try NSUserDefaults. Each approach is different and has different benefits vs. downfalls.
EDIT:
If you plan on releasing your software to the public, be careful of saving confidential information. ie: passwords, access tokens etc. This can be a very costly mistake depending where you are based legally.
Upvotes: 1