NSUserDefaults key removed randomly on iOS10

I caches some user's preference info in standardUserDefaults. But recently I notice that my custom key-value in NSUserDefaults randomly cleared. It means that sometimes after launching my App, all in-app setting infos are lost.

I cannot tell any method to reproduce this issue. It seems happen randomly.


P.S. Today iOS 10 Beta 8 released. I will try the latest version some days to ensure this issue still existing.


===== 2016.8.27 19:52(+8:00) updated =====

Yes I just reproduced this issue once again on iOS 10 Beta 8... But I still don't know why it happened.

Replies

To the top of the manual! Is there anyone help us?

My situation is same with you, but I'm running on iOS10.0.1, which released recently, and it's the first version of iOS10 to public.

My production application is same after upgrading ios 10.0.1.

Please help us!

We are seeing something similar with our production app on devices running iOS 10

We are seeing the intermitently as well. We had a theory that it was related to privateData not be ready on launch, but our fix for that has not worked.


We are pretty sure it is an issue in iOS, but it would be great to have clarity.

Do you have any updates on this issue? We're seeing a spike in our analytics that correlates with the release of iOS10 that relies on a flag we're setting in NSUserDefaults

We are having the same issue with UserDefaults and iOS10. One out of X times the app is opened user defaults returns nil. If the app is killed and opened again, the same user defaults returns the correct value, so the contents are not being deleted, they are just returned as nil.


We have tried to check if 'isProtectedDataAvailable', before checking User Defaults, but we have proved that the mehod returns 'true' even when user defaults is returning nil.


This is very inconvenient as we can't really trust the contens of UserDefaults anymore. We were using that storage to detect new installations, and the behaviour of the app will change based on that flag.


We are able to reproduce this issue running a sample project on a device over and over again. During the first run, we will store a flag in User defaults and we will automatically open and close the app until something fails. After a few iterations (~250), user defaults returns nil, but next time the app is opened it will work fine. We have opened a bug report for this issue but we haven't heard anything back yet, I will recomend you to open a bug report with details of the issue that you are seeing.

We just started seeing this when we put out a new version of our app compiled against the iOS 10 SDK. It only seems to affect apps compiled against the iOS 10 SDK when running on iOS 10 (iOS 9 SDK + iOS 10 is fine, as is iOS 10 SDK + iOS 9).


Have you found a reliable workaround?

We still se this behaviour happening randomly. Any ideas or updates on this?