Objective-c – Best way to save data on the iPhone

iphoneobjective c

I am writing an iPhone application, and need to save the state of my application (5K or so).

My main worry is data persisting across upgrades. Some of the applications I use clearly got this wrong, and I would prefer not to!

Best Answer

To save state, NSUserDefaults is the way to go. I believe most, if not all, instances of application data being deleted after an upgrade are due to issues on the AppStore. They may be related to data-format changes, but if you use just NSUserDefaults and standard plist-storable objects (NSString, NSDictionary, NSNumber, NSArray, NSNumber, and primitives), you should be safe.