Lost data in UserDefaults

My app user sometimes lost data in UserDefaults when our app launched.

All or part of the data is lost.
A device that has happened once is likely to happen again.
This bug seems to have been around since October 2020.
Not depend on any OS or hardware, and we haven’t been able to reproduce it yet.

Does anyone face the same bug?

A customer just reached out regarding the data loss in user defaults again. Don't know the iOS version yet and have asked them to confirm. @eskimo Any updates on this?

Any updates on this?

On what specifically? This thread has spanned a wide range of potential issues, all with the same symptoms. Some of them are absolutely no longer relevant (prewarming), some of them are definitely still relevant (data protection), and some of them will forever be relevant (the expected use case for user defaults).

Speaking of that last point, I’m surprised that I haven’t mentioned this earlier on this thread (I’ve highlighted it many other times here on DevForums). User defaults is intended to be used for preferences. If your data is important enough that customers get grumpy when it goes away, IMO you shouldn’t be storing it in user defaults.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

In the last month or so (probably since the release of iOS 17.2), I've started getting a lot of reports of users losing all their NSUserDefaults as well. I never had a problem with the prewarming stuff from iOS 15 - this is a completely new issue.

Has anyone else been experiencing anything like this on iOS 17? @eskimo - have there been any recent changes to iOS that might affected NSUserDefaults?

Lost data in UserDefaults
 
 
Q