In Xcode 13, using the 14.5 and 15.0 simulators, when I use UserDefaults to save preferences for the user, the defaults seem to go away when the app quits (I am using the home button / app switcher / slide up gesture to quit the app in the simulator).
This problem does not occur when using my actual devices (iPad and iPhone).
[userDefaults synchronize]
returns YES
, however I am getting nil
for the key I saved upon next launch.
Note: I am using NSKeyedArchiver archivedDataWithRootObject
with requiresSecureCoding
set to YES
for some keys, however the first key is not using NSKeyedArchiver
and is also returning nil
.