AlamoFire with Swift 1.2: Ambiguous use of 'responseJSON'

alamofire, swift

Solution

I have also gotten the following to work:

    Alamofire.manager.request(.PUT, pathWithId(user.key), parameters: user.toDict(), encoding: .JSON)
    .responseString( completionHandler: {
        (request: NSURLRequest, response: NSHTTPURLResponse?, responseBody: String?, error: NSError?) -> Void in
            if responseBody == "OK" {
                completion(user, nil)
            } else {
                completion(nil, error)
            }
    })

i.e. by explicitly stating the parameter name of the closure instead of letting it trail after the method paranthesis. It seems that the new compiler has a problem identifying the method otherwise.

Problem

I'm attempting to use AlamoFire with Swift 1.2 in XCode 6.3. I've fixed most of the problems (i.e. changing as to as!) but I have one that I can't figure out. The following code - and snippets like it - generates a compile time error with the message "Ambiguous use of 'responseJSON'" at the line 5 ("req.responseJSON(){"). What do I need to change in the AlamoFire library or my code to fix it? Note: I imported the project as described in the documentation and it worked fantastic in Swift 1.1 and XCode 6.1.1 ``` func theaters(delegate:GlobalNetworkingDelegate){ if let url = self.mainNetworkingUrl{ var urlToUse = url + "theaters" var req:Request = Alamofire.request(.GET, urlToUse, parameters: [:], encoding: .URL) req.responseJSON(){ (req, response, jsonOut, error) in if(response.statusCode == 200 && error == nil){ var ajson = JSON(jsonOut!) delegate.globalTheatersOutomce!(true, json: jsonOut, error: error) } } } } ```

Original source