CodableWrappers
CodableWrappers copied to clipboard
Can I combine OptionalCoding<BoolAsIntCoding> with FallbackEncoding<EmptyBool>?
Hello, is it possible to combine the following two wrappers in some way?
public struct EmptyBoolTrue: FallbackValueProvider {
public static var defaultValue: Bool { true }
}
@OptionalCoding<BoolAsIntCoding>
@FallbackEncoding<EmptyBoolTrue>
var autoRenewWarning: Bool?
The server sends 1 and 0 for booleans and I use Bool locally. What I would like to achieve is to set a default value of 1 or true whichever is possible if the key is missing or null but it seems the above two cannot be combined because one expects Int and the other Bool. How should I proceed regarding this, is there anything similar implemented that I can use as reference?
I've a similar need: I'd like to combine SecondsSince1970DateCoding with a fallback of Date().
Combining wrappers is generally rough/complex. I'm going to be looking at moving at least some wrappers to Macros which should simplify things. I will re-evaluate this then :)