In my SpriteKit game, I use UserDefaults to maintain high scores, etc. It works well, everything works smoothly.
however - I just upgraded some devices to iOS 10.3 (release, not beta), and I noticed that previously saved data is erased ...
new data is saved - for example, a new high score is recorded, so userDefaults are still installed after they are created .. but I would not expect 10.3 to erase the old data?
I assume this is due to the new APFS?
I have not tested this in other applications yet - has anyone else seen this problem? any idea how to prevent this from happening again?
thanks.
example of setting the default value: (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) }
source share