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
So, it's clear to me how to unmarshal a Date, by extending it with the ValueType protocol. But it's not at all clear how to marshal it. I tried various forms of this:
extension
Date : ValueType, Marshaling
{
public
static
func
value(from inObj: Any)
throws
-> Date
{
guard
let timeInterval = inObj as? Double
else
{
throw MarshalError.typeMismatch(expected: Double.self, actual: type(of: inObj))
}
let date = Date(timeIntervalSinceReferenceDate: timeInterval)
return date
}
public
func
marshaled()
-> Double
{
return self.timeIntervalSinceReferenceDate
}
}
But Xcode doesn't like it. In this case, it says Type 'Date' does not conform to protocol 'Marshaling'. Not sure what I'm doing wrong.
The text was updated successfully, but these errors were encountered:
So, it's clear to me how to unmarshal a Date, by extending it with the
ValueType
protocol. But it's not at all clear how to marshal it. I tried various forms of this:But Xcode doesn't like it. In this case, it says
Type 'Date' does not conform to protocol 'Marshaling'
. Not sure what I'm doing wrong.The text was updated successfully, but these errors were encountered: