简体   繁体   English

Alamofire上下文类型的关闭错误

[英]Alamofire Contextual type for closure Error

I have the following error after upgrading Alamofire to version 2.0.0.0 using Swift 2 使用Swift 2将Alamofire升级到2.0.0.0版后出现以下错误

在此处输入图片说明

Anyone know a fix for this? 有人知道解决办法吗?

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 . 现在,您需要提供一个接受requestresponseresult的闭包。 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.

相关问题 快速访问类文件时上下文关闭类型错误 - Contextual closure type error when accessing the class file in swift 上下文闭包类型 '(Data?, URLResponse?, Error?) -&gt; Void' 需要 3 arguments,但闭包主体中使用了 1 - Contextual closure type '(Data?, URLResponse?, Error?) -> Void' expects 3 arguments, but 1 was used in closure body 上下文闭包类型……期望 2 个 arguments,但闭包体中使用了 3 个 - Contextual closure type … expects 2 arguments, but 3 were used in closure body Alamofire无法在当前上下文中推断闭包类型 - Alamofire Unable to infer closure type in the current context 上下文关闭类型“响应” <AnyObject, NSError> -&gt; Void&#39;期望有1个参数,但在闭包主体中使用了4个 - Contextual closure type 'Response<AnyObject, NSError> -> Void' expects 1 argument, but 4 were used in closure body 上下文闭包类型响应 <AnyObject> - &gt;无效期待1个agrument,但3个在封闭体中 - Contextual closure type Response<AnyObject> -> void expects 1 agrument but 3 were in closure body 上下文闭包类型 &#39;(Any?) -&gt; Void&#39; 需要 1 个参数,但在闭包主体中使用了 2 个 - Contextual closure type '(Any?) -> Void' expects 1 argument, but 2 were used in closure body 如何修复上下文闭包类型&#39;(((String,JSON),(String,JSON))-&gt; Bool&#39;需要2个参数,但是在闭包主体中使用了1个? - How to fix Contextual closure type '((String, JSON), (String, JSON)) -> Bool' expects 2 arguments, but 1 was used in closure body? 使用 Swift 时出现错误“nil 需要上下文类型” - Error "nil requires a contextual type" using Swift 在 Alamofire 闭包中添加注解 - Add Annocation in Alamofire closure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM