Closed mortenholmgaard closed 5 years ago
This is not a bug in SwiftyUserDefaults
but rather a default behavior of underlying UserDefaults
which do save settings only at certain times in the lifecycle of the app. Typically reruning the app from Xcode will kill it without giving it any chance to persist the settings to the permanent storage.
If you want to make sure settings are stored immediately there is a method UserDefaults.standard.synchronize()
IIRC.
Not sure if SwiftyUserDefaults provides interface for this.
Okay makes sense - thanks.
There seems to be some problem with values not getting saved or not saved right away. I have testede different tings and the results varies from run to run.
I have a intro flow with 3 screens each setting a Defaults value when completed and then on next open starting at the step they left of, if not completed all of them.
When I got through the flow and then reruns/installs the app from xcode it is different amost each time how many steps that has been completed - which states that has been saved. But it seems like when it gets its time they will be saved. But it is just strange..