我正在尝试使用 Swift 4.0 Codable 协议序列化我的对象。尝试解码闭包属性时遇到错误:
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)'
我想这是可以理解的,但肯定有一些我可以使用的策略(毕竟,函数是一流的对象,对吧?)。我必须以某种方式包装我的闭包吗?