I'm trying to serialize my objects with the Swift 4.0 Codable protocol. I'm hitting an error when trying to decode closure properties:
guard let influenceFunction = try? container.decode(((E, Double) -> (E))!.self, forKey: TransformCodingKeys.influenceFunction) else {
// ... do something clever ...
print("sad times...")
}
Cannot invoke 'decode' with an argument list of type '(((E, Double) -> (E))!.Type, forKey: TransformCodingKeys)'
Understandable enough, I suppose, but surely there must be some strategy I can use (after all, functions are first-class objects, right?). Do I have to wrap my closures somehow?
You can use a trick to solve that: