给定班级:
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)
}
}
}
我想调用编码函数的默认实现,但完整的情况是一个无限循环。我不想创建 CodingKeys,有什么办法吗?或者也许复制默认实现:/。