I noticed a ton of updates kill user data -- is this just an unfortunate side effect of updating that can't be overcome? I can understand if the game is updated in such a way that the old data isn't really relevant, or keeping the old data / scores doesn't make sense because the scoring can't be compared to the new version. However, I'd try everything I could to preserve my user's data at all costs, which leads me to believe that this loss of data is not the developer's fault. Does anyone have any insight? The latest example I've heard of is Zombieville USA, which apparently erases the scores / records after the update.
I would say that's game dependent. I've had plenty of games that have survived updates just fine, and in fact can't think of one that's lost data. Of course, as long as my save games are in tact I don't tend to pay too much attention to anything else.
If an app loses data after an update, that's entirely the developer's fault. There's no data loss expected from the upgrade itself.
As a developer, how would I ensure high scores/user data doesn't get wiped during an update? If I were to create a plist with user data from scratch once the app was run for the first time, would that work? How does the update process work? Will it just overlay files onto the existing app directory? or does it delete the current app's folder first?
Puzzlequest still carries my data after multiple updates, zombieville usa is one of the only games which has cleared my top score after an update but it has a valid reason, the game is much better and slightly different now.
I had/have the same question too. That's exactly why I thought the updates were causing my data to be lost -- that the save was simply being overwritten. Good to hear that's not the case, and that data can be preserved. I've seen the issue so far with Zombieville / Creeps!, and it's made me hesitant to upgrade a few of my other apps. If anyone has information about what exactly happens during an update I'd be interested to hear it; in the meantime, I'll do some digging myself.
Not entirely true. The first couple months the App Store was open, Apple had a random update bug that wiped all user data when the update happened. You'd see the bug pop up all the time in various app user reviews, and the dev would get the blame, when really, it all happened before the app was ever launched. However, nowadays the bug happens rarely. But it's always a fear in the back of our minds.
If everything goes according to plan, Apple overwrites everything except the data in the app's Documents directory. This is generally where devs store local user data. During this whole process, the app is not started, which means the dev has zero control over anything. Once the app is launched the first time, it's up to the dev to read the user data correctly.
So if we want the update to continue reading the old data, we'd keep the reference (dictionary name for example) the same, but if we actually want the update to start over, we'd change the reference name so it won't load the old one, right?
Seems reasonable, as long as the data you're talking about is kept in the Documents folder. It's easy enough to test. Just load your app, and write out your saved data. Then, load a newer build of your app over the top of the old one, without deleting the old one first. The app will get replaced, but the user data should still be there. What you do with that user data when your app loads is up to you.
I've seen that you can use NSUserDefaults for this - but does anyone know if it will survive an update? It looks like the quickest way to store a lot of information.
NSUserDefaults-stored data will survive an app update. Anything in the ~/Documents or ~/Library folders should be fine. Of course, if the user deletes the old version before updating, then they'll lose everything. B
The upcoming 1.2.0 version of "The Creeps!" (waiting for Apple approval right now) will not lose your scores or unlocked levels no matter what version you upgrade from. I made sure of it this time!