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
{{ message }}
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
I have a bit of inheritance in my codable objects and MessagePack crashes when encoding one of these. I could simplify the code to reproduce the crash to this:
func testMessagePack() {
do {
let testerB = TesterB()
let encoder = MessagePackEncoder()
let data = try encoder.encode(testerB)
} catch {
return
}
}
}
class TesterA: Codable {
var fun = 1
}
class TesterB: TesterA {
enum CodingKeys: CodingKey {
case foo
}
var foo = 2
override func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(foo, forKey: .foo)
try super.encode(to: encoder)
}
}
I checked the code and saw there could be only one container. What would be the best way to add support for any number of containers? I was thinking of just storing an array of them and just set container to the array.last, what do you think?
Cheers,
S.
The text was updated successfully, but these errors were encountered:
Hi!
I have a bit of inheritance in my codable objects and MessagePack crashes when encoding one of these. I could simplify the code to reproduce the crash to this:
I checked the code and saw there could be only one container. What would be the best way to add support for any number of containers? I was thinking of just storing an array of them and just set container to the array.last, what do you think?
Cheers,
S.
The text was updated successfully, but these errors were encountered: