What would you consider the proper way of storing a simple username string in your app, so that it is there when you open the app again? I’ve been reading of a couple of ways to do so: core data, plist, nsuserdefaults.
What are some of the ways people are using to do this, and if possible pros and cons of the proposed way?
Core Data is serialized into SQLite, and makes more sense for when you’re dealing with many objects and dynamically creating/deleting them.
Plists fall somewhere between the complexity of Core Data and NSUserDefaults. They can handle data with some structure, and are saved as a file on the filesystem.
Since you’re just dealing with one piece of information, NSUserDefaults makes the most sense for you. All you have to do to save a string is:
Then, to retrieve the string: