0
我试图从一个传递给我的函数的类创建一个对象。问题是我无法传递任何参数给它的构造函数,因为我看不到initialize
这个类有参数。带参数的Swift类型反射初始化
这是我的代码至今:
class func invokeService<T: Initable>(service: String, returningClass: T.Type, completionHandler handler: ((T) ->())) {
var interfaceObject = returningClass()
interfaceObject.self(data: service as Dictionary <String, AnyObject>)
handler(interfaceObject)
}
这是错误我得到:
'(data: Dictionary <String, AnyObject>)-> $T2' is not identical to 'T'