Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alamofire complaining about argument types

In the code below, Alamofire is complaining that it "Cannot invoke 'responseJSON' with an argument list of type ((_, _, _, _) -> _)." The same issue occurs when using 'response.'

    func request(parameters: [String : AnyObject?], completionHandler: ((NSURLRequest, NSHTTPURLResponse?, AnyObject?, NSError?) -> Void)) -> Void {
      Alamofire.request(.POST, "localhost:8080/reserve", parameters:
            ["refreshToken": refreshToken,
             "accessToken": accessToken,
             "deviceToken": deviceToken],
            encoding: .JSON)
      .responseJSON { (request, response, data, error) in
            completionHandler(request, response, data, error)
      }
   }

Why is this occuring?

like image 892
joshim5 Avatar asked Dec 20 '22 04:12

joshim5


1 Answers

Your parameters argument is bad typed. It should be [String: AnyObject]? instead of [String : AnyObject?].

Fixing this error, you should be able to compile again.

Otherwise, ensure your token variables exist. If not, the compiler is confused, and the error is not actually due to Alamofire.

like image 99
Adrien Cadet Avatar answered Dec 24 '22 02:12

Adrien Cadet