Defining function error using generics

巧了我就是萌 提交于 2019-12-13 08:47:15

问题


Here's the code:

extension Alamofire.Request {
public func responseObject<T: ResponseJSONObjectSerializable> (completionHandler: (NSURLRequest?, NSHTTPURLResponse?, Result<T> -> Void) -> Self {
//Error1: expected ',' separator
//Error2: expected parameter type following ':'

    ...

)
}

I'm using Swift 2.0, Alamofire 3.0, and SwiftyJSON.


回答1:


Problem solved: there's a mistake of parenthesis in the code, the ) should be place behind result<T> rather than the end of the function.

I thought it was some serious problem, took me a long time to find this. :P



来源:https://stackoverflow.com/questions/33010256/defining-function-error-using-generics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!