Is data persisted in NSUserDefaults between app launches? I want some small data to be persisted even if I quit and relaunch the app.
Asked
Active
Viewed 4,272 times
2 Answers
9
Yes.
Data will persist in NSUserDefaults
for the entire lifetime of the app.

Jacob Relkin
- 161,348
- 33
- 346
- 320
-
I use it for storing the user's login name. – Aurum Aquila Jan 23 '11 at 02:14
-
7Until the app is deleted from an iOS device. Even then, a restore from backup to a new device will also restore NSUserDefaults. – hotpaw2 Jan 23 '11 at 02:41
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
-
-
I believe that he was talking about NSUserDefaults on the Mac. It's easily deleted there, as it's just a Plist. – Aurum Aquila Jan 23 '11 at 02:14
-