Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is data stored in NSUserDefaults persists through application updates and on application reinstallation (remove-install)?

It's important to my app, becuase I want to store app UDID there, and Apple recommends to create app specific UDID starting from iOS 5.0.

like image 522
M.Y. Avatar asked Feb 06 '12 16:02

M.Y.


People also ask

Where NSUserDefaults data is saved?

The user's defaults database is stored on disk as a property list or plist. A property list or plist is an XML file. At runtime, the UserDefaults class keeps the contents of the property list in memory to improve performance. Changes are made synchronously within the process of your application.

How does NSUserDefaults work?

NSUserDefaults caches the information to avoid having to open the user's defaults database each time you need a default value. When you set a default value, it's changed synchronously within your process, and asynchronously to persistent storage and other processes.

What is NSUserDefaults in swift?

A property list, or NSUserDefaults can store any type of object that can be converted to an NSData object. It would require any custom class to implement that capability, but if it does, that can be stored as an NSData. These are the only types that can be stored directly.


1 Answers

User defaults are persisted through updates but are not persisted through deleting and re-installing the app. At present, the keychain is persisted through deleting and re-installing the app, but it's not documented to be one way or the other, so relying on this behavior may be risky.

You could also write the value to the iCloud key/value store. That will be persisted across all installations of the app for that user and is kind of what it was designed for.

like image 69
Jason Coco Avatar answered Oct 21 '22 22:10

Jason Coco