简体   繁体   中英

Alamofire Contextual type for closure Error

I have the following error after upgrading Alamofire to version 2.0.0.0 using Swift 2

在此处输入图片说明

Anyone know a fix for this?

The Request Serialisation, ie responseJson changed signatures in 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 . The result is an enum , which can either be .Success(Value) or .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)
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM