0

i am trying to work on nsuserdefaults but few things are confusing me in apple reference and setting guide they says

Preferences are pieces of information that you store persistently and use to configure your app. Apps often expose preferences to users so that they can customize the appearance and behavior of the app. Most preferences are stored locally using the Cocoa preferences system—known as the user defaults system. Apps can also store preferences in a user’s iCloud account using the key-value store.

The user defaults system and key-value store are both designed for storing simple data types—strings, numbers, dates, Boolean values, URLs, data objects, and so forth—in a property list. The use of a property list also means you can organize your preference data using array and dictionary types. It is also possible to store other objects in a property list by encoding them into an NSData object first.

but what is users defaults system and further on in this guide they say users defaults database... if they are talking about database then why here they wrote use of plist?

similar question but not helping me

thanks in advance.

Community
  • 1
  • 1
supera
  • 580
  • 5
  • 13

1 Answers1

3

NSUserDefaults is a key value store for saving preferences. It works very much like an NSDictionary where you insert an object for a key, and pull it out.

Since the object needs to be saved to disk, only plist serializable objects work, unless you turn them into NSData first.

It is not the type of database you can run SQL queries on.

Randall
  • 14,691
  • 7
  • 40
  • 60
  • thanks for reply...i understand that what u wrote in reply...but i am still not clear what apple guide is saying.. is it stored in plist or some other database... – supera Jan 27 '12 at 06:37
  • Why do you care how it is stored? Apple provides the API to access NSUserDefaults in a manner that is independent of its implementation details. – UIAdam Jan 27 '12 at 09:10
  • They're stored in a plist file. You can see in this question where they're stores. http://stackoverflow.com/questions/1676938/easy-way-to-see-saved-nsuserdefaults – Randall Jan 27 '12 at 14:44