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
enum LogValue: Codable, RealmableEnum {
case sugar(SugarLogCreate)
case carb(CarbLog)
case weight(WeightLog)
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let x = try? container.decode(SugarLogCreate.self) {
self = .sugar(x)
return
}
if let x = try? container.decode(CarbLog.self) {
self = .carb(x)
return
}
if let x = try? container.decode(WeightLog.self) {
self = .weight(x)
return
}
throw DecodingError.typeMismatch(LogValue.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for Log Value"))
}
func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .sugar(let x):
try container.encode(x)
case .carb(let x):
try container.encode(x)
case .weight(let x):
try container.encode(x)
}
}
}
where each SugarLogCreate, CarbLog and WeightLog are structs conforming toRealmable
I get this error that tells me I have not conformed to RealmableEnums "Type 'LogValue' does not conform to protocol 'RealmableEnum'"
and makes me put these methods in my code which I have no idea what to do with them:
func rlmValue() -> Any {
<#code#>
}
init?(rlmValue: Any) {
<#code#>
}
static var rawValueType: Any.Type
What should I do in this case?
Thank you in advance for your reply.
The text was updated successfully, but these errors were encountered:
Hi I have this enum with associated types
where each
SugarLogCreate
,CarbLog
andWeightLog
are structs conforming toRealmable
I get this error that tells me I have not conformed to
RealmableEnums
"Type 'LogValue' does not conform to protocol 'RealmableEnum'"
and makes me put these methods in my code which I have no idea what to do with them:
What should I do in this case?
Thank you in advance for your reply.
The text was updated successfully, but these errors were encountered: