Within my app I’ve been storing variables in the NSUserDefaults, these variables are increased by in-app purchases within the app. My question is whether when the app is updated will these variables will remain so that the user can still access them after the update.
Additionally what’s the best practice for storing variables of this sort; what do Apple recommend?
NSUserDefaults data doesn’t get removed between app updates unless the user uninstalls and reinstalls the app. It also gets stored in backups (both via iTunes and iCloud), so as long as the user has one of those set up and doesn’t uninstall the app, you can rely on the data persisting.
As a side note, you should probably be encrypting the values you store in the defaults—the file is user-accessible, which makes it possible to tamper with.