Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do NSUserDefaults persist through an Update to an app in the Appstore?

Is this the case? Do NSUserDefaults get reset when you submit an update to an app on the App Store, or are they reset?

My app is crashing when updated but not crashing when downloaded fully - so I'm trying to determine what could possibly be different in the updated session to the freshly downloaded session.

Cheers, Nick.

like image 634
Nick Cartwright Avatar asked Oct 28 '09 17:10

Nick Cartwright


People also ask

What types can you store natively in NSUserDefaults?

Types stored in NSUserDefaultsplist type can be stored by NSUserDefaults . These types are NSString(String) , NSArray(Array) , NSDictionary(Dictionary) (for both NSArray and NSDictionary types their contents must be property list objects), NSNumber(Int, Float, Double, Boolean) , NSDate and NSData .

What is NSUserDefaults?

The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an app to customize its behavior to match a user's preferences. For example, you can allow users to specify their preferred units of measurement or media playback speed.

Is NSUserDefaults thread safe?

The NSUserDefaults class is thread-safe.


3 Answers

They are usually not reset unless the user deletes the app. For basic data, NSUserDefaults is the best way to save data such as preferences, dates, strings etc. If you are looking to save images and files, the file system is a better bet.

like image 51
coneybeare Avatar answered Nov 02 '22 22:11

coneybeare


I beleive the answer is YES, it will persist. This also fully documented under the Application Directory chapter in the Apple iPhone OS Programming Guide.

like image 39
leon Avatar answered Nov 02 '22 22:11

leon


  1. Direct answer to the posted question: YES.
  2. Your problem: Your app gets crashed due to logic issues. Suppose you store an object in defaults and the app checks it's value on launch (or elsewhere). In you update you could change the way it is checked or used, e.g. you expect a value, but the object is nil, or vice versa. This may cause a SIGABRT or EXC_BAD_ACCESS.
like image 41
John Smith Avatar answered Nov 02 '22 22:11

John Smith