Given the class:
class ComplementApp: Codable {
enum TypeCoder: String, Codable {
case full, singleVal
}
var id_spring: String = ""
var nombre: String = ""
var typeCoder: TypeCoder = .full
func encode(to encoder: Encoder) throws {
switch typeCoder{
case .singleVal:
var container = encoder.singleValueContainer()
try container.encode(id_spring)
case .full:
//Here is the bug
try (self as Encodable).encode(to: encoder)
}
}
}
I want to call the default implementation of encode function, but the full case is an infinite loop. I don't want to create CodingKeys, is there some way? Or maybe replicate the default implementation :/.