6

In my SpriteKit game I use UserDefaults to save high scores etc. Works fine, everything working smoothly.

however - I just updated some devices to iOS 10.3 (release, not beta) and I noticed that previously saved data is wiped...

new data is preserved - eg - a new high score is recorded, so the userDefaults are still being set once they are created.. but I wouldn't have expected 10.3 to wipe the old data ??

I imagine this is something to do with the new APFS ?

I have not tested this in any other apps yet - has anyone else seen this issue ? any idea how to prevent this happening in future ?

thanks.

example of setting a default: (Swift 3)

if (UserDefaults.standard.value(forKey: "highScoreLife") == nil) {
    highScoreLife = 0
    UserDefaults.standard.set(highScoreLife, forKey: "highScoreLife") } else {
    highScoreLife = Int32(UserDefaults.standard.integer(forKey: "highScoreLife") as Int)
}
Adam
  • 373
  • 4
  • 13
  • Testing something like that is going to be next to impossible since you can't downgrade – Knight0fDragon Mar 28 '17 at 14:39
  • Interesting question, and hopefully there is nothing wrong with a new APFS. I have shared this question as much as I could thought, and one of mine friends are testing this right now, so I will get back with the results soon. – Whirlwind Mar 28 '17 at 14:59
  • So the results of the tests... It worked on two devices so far. – Whirlwind Mar 28 '17 at 16:19
  • it worked as in - the user defaults were not wiped ? interesting! i've tested on 3 devices that had defaults set and were all wiped. going from 10.2.whatever to 10.3.. weird. – Adam Mar 28 '17 at 17:28
  • i've only got one more device i can test on!! no idea what is going on here... – Adam Mar 28 '17 at 19:56
  • 1
    well, that's odd. my final test worked fine - user data was not wiped... OK I guess !? – Adam Mar 28 '17 at 22:05

0 Answers0