2

In my spritekit app, I have Chapters which contain 30 levels. All of the levels are initially locked. Once a level is won, the next level is unlocked. NSUserDefaults does not seem like an ideal choice. I tried to save my data in a plist file in the "application support" folder by having an array for each level pack and a value (1 or 0 depending on the level's status) that corresponds to each level. This also did not seem ideal because it could be edited and would be reset with an update.

My goal is to have this data persist through an app Update and not be easily edited by a user. Are there any good solutions for this?

Greencat
  • 142
  • 12
  • 1
    you can use sqlite database for that. it will be a great solution for this issue – Tejas Ardeshna Apr 03 '15 at 06:06
  • 1
    you can also use cloud save, eg. with Parse api set, which also supports local datastore when network is not available. – nzs Apr 03 '15 at 08:04
  • 2
    Different ways to store game progress : http://stackoverflow.com/questions/27566483/storing-game-preferences-and-saved-games-in-a-secure-format – Whirlwind Apr 03 '15 at 11:22

2 Answers2

2

NSUserDefaults is a actually a very good way to store data like this. You are after all only talking about storing BOOL values. NSUserDefaults is not reset or deleted during an app update unless the user deletes the app. This is stated in the iPhone iOS Programming Guide, Files Saved During Update (page 114):

When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation.

As Whirlwind already commented, there are many ways to store data. Here is a link to a previous question dealing with various storage methods.

Community
  • 1
  • 1
sangony
  • 11,636
  • 4
  • 39
  • 55
0

You can serialize your property list and store it as data into the NSUserDefaults. You can also encrypt it before storing, to ensure nobody can modify it in any way.

Apple Docs for plist serialization https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/PropertyLists/SerializePlist/SerializePlist.html

ben
  • 900
  • 9
  • 17