Cannot call value of non-function type 'NSHTTPURLResponse?' Alamofire ObjectMapper

后端 未结 2 2017
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 00:25

Cannot call value of non-function type \'NSHTTPURLResponse?\'

Can someone please help me here?

Here is the code

   public func responseObjec         


        
相关标签:
2条回答
  • 2021-01-18 01:00

    You need to mark your completionHandler as @escaping.

    0 讨论(0)
  • 2021-01-18 01:10

    Had this error myself and took a while to figure out why it was occurring. It looks like if the parameters to the response() method call don't match to any method declarations then swift assumes your code is referring to the response property, a NSHTTPURLResponse. Because there the property that "shadows" the method's name, swift can't help you out with errors that indicate which parameter is a problem, it just punts on matching to any method.

    In my case, completionHandler was mismatched because of its parameters. Note, its the sample code I saw .response { response in ... } that's problematic. There's no response method taking a "response in" closure like there is for the responseString, responseJSON, etc. methods.

    That said, Abh, I can't tell from looking what the exact issue is with your code.

    0 讨论(0)
提交回复
热议问题