Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I combine OptionalCoding<BoolAsIntCoding> with FallbackEncoding<EmptyBool>? #27

Closed
CochiorasBogdan opened this issue Feb 21, 2022 · 2 comments

Comments

@CochiorasBogdan
Copy link

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?

@futuretap
Copy link

I've a similar need: I'd like to combine SecondsSince1970DateCoding with a fallback of Date().

@GottaGetSwifty
Copy link
Owner

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants