我有一个协议被定义为
func get<T: ApiModel, TError: ApiModel>(url: String, params : [String : AnyObject]?, headers : [String : String]?, success:(T)->Void, error:(TError?, NSError)->Void) -> Void;试图把它称为
self.webClient.get("http://google.com", params: nil, headers: headers, success: { (response: ConcreteClass) in
}, error: { (errorModel:ConcreteErrorClass, error: NSError) in
})这将导致以下错误:
'Cannot convert value of type (ConcreteClass) -> ()' to expected argument type '(_) -> Void'发布于 2016-05-06 15:45:01
在您调用的方法的声明中,error:闭包有可选类型(error:(TError?, NSError)->Void)的第一个参数,但是您用非可选类型声明了它。这可能就是原因(事实上,Swift有时会产生非常不相关的错误消息)。
https://stackoverflow.com/questions/37076209
复制相似问题