views:

78

answers:

1

What's the best way of dealing with variables in constant use in an iPhone app, like username/password in a twitter client?

+1  A: 

If you are using them all over, you can store them in either the AppDelegate or an object referred to by the app delegate.

Another popular option if the data is only needed by a small section of the app, is to create a singleton class where you ask it for the current instance and store what you need there.

If you'd like the data to persist, then you really want to use either a database (CoreData is nice) or NSUserDefaults to hold values. Since you mentioned twitter usernames/passwords specifically, note that you should really hold onto data like that in the keychain, so that it is stored in encrypted form.

Kendall Helmstetter Gelner