SamoanProgrammer
SamoanProgrammer

Reputation: 954

Alamofire Contextual type for closure Error

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

enter image description here

Anyone know a fix for this?

Upvotes: 0

Views: 219

Answers (1)

Josh Heald
Josh Heald

Reputation: 3947

The Request Serialisation, i.e. 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)
    }

Upvotes: 1

Related Questions