[英]Alamofire Contextual type for closure Error
The Request Serialisation, ie responseJson
changed signatures in AlamoFire 2.0. 请求序列化,即responseJson
更改了AlamoFire 2.0中的签名。 The Migration Guide explains in full, but the abbreviated version is as follows. 《 迁移指南》有完整的解释,但缩写版本如下。
You now need to supply a closure which takes a request
, a response
, and a result
. 现在,您需要提供一个接受request
, response
和result
的闭包。 The result is an enum
, which can either be .Success(Value)
or .Failure(NSData?, ErrorType)
. 结果是一个enum
,可以是.Failure(NSData?, ErrorType)
.Success(Value)
或.Failure(NSData?, ErrorType)
。
So your code should look something like this: 因此,您的代码应如下所示:
Alamofire.request(.GET, urlString, parameters: params, encoding: .URL)
.responseJson(options: .MutableContainers) { (request, response, result) -> Void in
print(result)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.