Why does the watch's NSUserDefaults reset when restarting the watch?

Hi,


I'm setting a Bool value in the watch's NSUserDefaults.standardUserDefaults() for "appsFirstRun". The watch is actually having no problem saving & keeping this Bool value UNTIL... I power down & restart the watch (not uninstall - restart). When I restart the watch, all values in the NSUserDefaults.standardUserDefaults() are cleared.


Any help in getting those defaults to stay saved after restarting would greatly be appreciated. Thanks in advance!

Replies

I have the same issue- in WatchOS 3.1 still. When the app is force-exited or the watch restarts, nsuserdefaults for the app is gone.

This has been driving me nuts. It all works fine on the simulator.


When I load it onto the S0 SS44mm (watchOS 4.3.2) on my wrist it works initially until the next day when I pick it up off the charger and put it on. Then I find that the NSUserDefaults value it stored has gone (an NSDate object).


This only seems to be an issue if I have my extension app as a complication. If I run it from the dock all is fine although I suspect that's because it is running it fresh and causing it to request the value from the main app on the iPhone. Running from the complication seems to freeze the app which makes the loss of the store value in NSUserDefaults noticable. If I remove the complication it un-freezes and updates itself.


Erasing NSUserDefaults just seems bat **** crazy. Isn't requesting data, and initiating Bluetooth comms, power inefficient and less preferential to storing locally? Or am I missing something?