You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tag appears in the decoder object, and we would like to be able to access that info, as this would tell us which polymorphic type to encode and decode. As it stands, we have to just keep trying each possibility until one or none worked. The problem we have is that the _Decoder class and its node property are both private. We can print them in the debugger and see that they are viewable, but we can't programmatically access them in our methods. Is there a way to access the tag during the call to init(from decoder:)?
An option that would work for me, is to be able to up front register specific types for specific tags.
Then the decoder could be allowed to do the work itself.
I'm not sure that this would be practical for @tjprescott 's case, though.
We have a data model schema that is using verbatim tags in YAML to indicate polymorphism. Note the protocol property in the below YAML snippet.
Here is
Protocols.swift
:So under
protocol
, thehttp
property could be one of a few different types. Here is the model forHttpParameter
(as indicated in the snippet):This requires us to supply the following methods to
Protocols
:The tag appears in the decoder object, and we would like to be able to access that info, as this would tell us which polymorphic type to encode and decode. As it stands, we have to just keep trying each possibility until one or none worked. The problem we have is that the
_Decoder
class and itsnode
property are both private. We can print them in the debugger and see that they are viewable, but we can't programmatically access them in our methods. Is there a way to access the tag during the call toinit(from decoder:)
?cc/ @sacheu
The text was updated successfully, but these errors were encountered: