sunshinejr / SwiftyUserDefaults

Modern Swift API for NSUserDefaults
http://radex.io/swift/nsuserdefaults/static
MIT License
4.85k stars 365 forks source link

Simultaneous accesses error when preference default value uses another preference #247

Closed dsalber closed 3 years ago

dsalber commented 4 years ago

I have a preference which uses another preference as its default value, something like:

var preference1: DefaultsKey { .init("preference1", defaultValue: 1) } var preference2: DefaultsKey { .init("preference2", defaultValue: Defaults.preference1) }

When I set preference2, I crash with "Simultaneous accesses to 0x..., but modification requires exclusive access". For instance: Defaults.preference2 = 10 // crashes

Demo project showing the problem attached. Just run it and it should crash.

SwiftyRedux.zip

edon2005 commented 4 years ago

The same is in my project :(

mortenholmgaard commented 4 years ago

I see the same behavior in my project.

This is related to this: https://github.com/sunshinejr/SwiftyUserDefaults/issues/241

dficken commented 4 years ago

Same here

moyoteg commented 3 years ago

same here

sunshinejr commented 3 years ago

Hey all. I just released 5.2.0 with the fix for that. Let me know if this helps - thanks!