userDefaults reset / wiped after iOS 10.3 update
Asked Answered
B

0

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)
}
Bramble answered 28/3, 2017 at 10:8 Comment(6)
Testing something like that is going to be next to impossible since you can't downgradeDehiscent
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.Dimmer
So the results of the tests... It worked on two devices so far.Dimmer
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.Bramble
i've only got one more device i can test on!! no idea what is going on here...Bramble
well, that's odd. my final test worked fine - user data was not wiped... OK I guess !?Bramble

© 2022 - 2024 — McMap. All rights reserved.