Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data persistence through NSUserDefaults

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

like image 274
Abhinav Avatar asked Mar 23 '26 20:03

Abhinav


2 Answers

Yes.

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

like image 143
Jacob Relkin Avatar answered Mar 25 '26 11:03

Jacob Relkin


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.

like image 41
Heng-Cheong Leong Avatar answered Mar 25 '26 11:03

Heng-Cheong Leong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!