Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharedPreferences on iOS 4

I am looking for a way to store data about a user in iOS 4 that is similar to SharedPreferences in Android. Android's SharedPreferences basically stores key value pairs for an application and only that application can access it. http://developer.android.com/reference/android/content/SharedPreferences.html

Does iOS 4 have something built in that can accomplish what SharedPreferences does in Android?

like image 310
Joshua Abrams Avatar asked Oct 24 '11 13:10

Joshua Abrams


1 Answers

NSUserDefaults is your choice.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html

Typically you'd like to:

  • use standard user defaults ([NSUserDefaults standardUserDefaults])
  • store preferences using -set*:ForKey: (* being int, double, bool, dictionary, object...)
  • retrieve them using -*ForKey:
  • -synchronize when needed
like image 191
ayoy Avatar answered Oct 16 '22 03:10

ayoy