2

Is data persisted in NSUserDefaults between app launches? I want some small data to be persisted even if I quit and relaunch the app.

Mike Abdullah
  • 14,933
  • 2
  • 50
  • 75
Abhinav
  • 37,684
  • 43
  • 191
  • 309

2 Answers2

9

Yes.

Data will persist in NSUserDefaults for the entire lifetime of the app.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
1

Data will persist. But, NSUserDefaults is used primarily for preferences. Users expect that it is okay to delete the preference file without affecting their documents and created data.

If the data is not a preference, you may want to store the data in a file inside ~/Library/Application Support/[your application's name]/ instead.

Heng-Cheong Leong
  • 824
  • 1
  • 8
  • 13