Alamofire 4: Cannot call value of non-function type 'HTTPURLResponse?'

91 Views Asked by At

Using Alamofire 4 with Swift 3.2. The code in question worked at one point, but I had to move it. Now no matter how I simplify it, it won't compile. I get the error "Cannot call value of non-function type 'HTTPURLResponse?'" on the .response( line.

override func doRequest(_ request : URLRequest, call: AlamoRequest) {
    Alamofire.request(request)
    .validate(statusCode: 200..<400)
    .response(completionHandler: { (theResponse) in
        self.delegate.handleUnserializedRequest(theResponse, call: call)
    })
}
1

There are 1 best solutions below

0
On

And as usual, the act of forcing myself to post this question actually immediately led me to the answer.

The problem was that my delegate's implementation of handleUnserializedRequest was a private method. Commenting it out was the clue, suddenly the error disappeared. Then I realized the problem was actually on the line in the completion method.