sunshinejr / SwiftyUserDefaults

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

Using this in extensions #282

Open crspybits opened 3 years ago

crspybits commented 3 years ago

I'd like to be able to save a value into user defaults with this library, and then retrieve the value in a sharing extension, or vice versa. E.g., see https://stackoverflow.com/questions/45607903/sharing-userdefaults-between-extensions

It looks like this isn't supported yet for this library. Any plans? Thanks!!

(I use your package here: https://github.com/crspybits/PersistentValue.git).

ky1vstar commented 3 years ago

@crspybits this IS supported. DefaultsAdapter has constructor which takes UserDefaults instance. You need to create to create UserDefaults with appropriate app group shared between your main app and app extensions.