sunshinejr / SwiftyUserDefaults

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

Encodable RawRepresentable enums do not conform to DefaultsSerializable #250

Open nikans opened 4 years ago

nikans commented 4 years ago
Screenshot 2020-05-23 at 04 45 39

It's ok if the raw representable enum type only conforms to Decodable, though.

vBoykoGit commented 4 years ago

Any solution here?

sunshinejr commented 4 years ago

@nikans @vBoykoGit please take a look at https://github.com/sunshinejr/SwiftyUserDefaults/issues/206 and let me know if it helps!

huybuidac commented 4 years ago

@nikans @vBoykoGit please take a look at #206 and let me know if it helps!

I'm facing the same problem and this also doesn't work. Can you help :(

image

sunshinejr commented 4 years ago

@huybuidac you need to also define _defaultsArray in addition to _defaults to fully implement the DefaultsSerializable protocol, e.g.:

public static var _defaults: DefaultsCodableBridge<Self> { return DefaultsCodableBridge() }
public static var _defaultsArray: DefaultsCodableBridge<[Self]> { return DefaultsCodableBridge() }