Reputation: 89
I've seen a lot of posts about this subject and the morre I read about that the more i am confused. I will explain what I want and I hope you can give me a good answer.
I have created a loginviewcontroller to a remote database. When the authentication was successful, the server returns the userID and a token. Now I want to keep this two variables the whole time, because i need them everytime i connect to the remote database (thats allways & everywhere).
So what is the best way to handle this.
I thought about a singleton but some people say its good and some say its bad.. Maybe the singleton solution is colpetely wrong, for what I want to do…?
So please tell me what is the best way to keep authentication data.
Thanks in advance!
Upvotes: 1
Views: 61
Reputation: 82535
Consider using the Keychain Services, particularly if you are storing authentication information persistently.
Upvotes: 0
Reputation: 62686
I have a custom subclass of NSMutableURLRequest
where I do all kinds of auth and other stuff specific to my server. I keep a couple of static NSStrings in that module. (It's even a little naughtier than a singleton, but take that singleton advice with a grain of salt...Singletons aren't satanic, they're just discouraged). Sometimes you really need to have just one of something.
Upvotes: 1