Question

I am developing an app where I want the user to be able to customize certain aspects of the app experience. I plan on providing a settings screen where they can toggle some options. What is the best way to save this data and have it persist between the app closing, phone resets, etc?

I know that I can do this with default settings, but that seems a little clunky . . . is there a better way?

Was it helpful?

Solution

NSUserDefaults is for user preferences, usually basic objects like NSString or NSNumber.

Sqlite, serializing a collection of objects in a property list, or Core Data are all valid options for storing user data such as model objects you created.

You're not going to see a speed difference, but it's still best to pick the correct mechanism for what you're doing. If it's just preferences then use NSUserDefaults, otherwise I would serialize your objects to a plist.

If you're new to Cocoa I would avoid Core Data and even sqlite at first, to give yourself a chance to learn the basics first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top