-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels