使用泛型定义函数错误 [英] Defining function error using generics
本文介绍了使用泛型定义函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是代码:
extension Alamofire.Request {
public func responseObject<T: ResponseJSONObjectSerializable> (completionHandler: (NSURLRequest?, NSHTTPURLResponse?, Result<T> -> Void) -> Self {
//Error1: expected ',' separator
//Error2: expected parameter type following ':'
...
)
}
我正在使用Swift 2.0,Alamofire 3.0和SwiftyJSON。
I'm using Swift 2.0, Alamofire 3.0, and SwiftyJSON.
推荐答案
问题已解决:代码中括号中有一个错误,)
应该放在 result< T>
的后面,而不是函数的结尾。
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.
我认为这是一个严重的问题,我花了很长时间才找到它。 :P
I thought it was some serious problem, took me a long time to find this. :P
这篇关于使用泛型定义函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文