【问题标题】:Cannot call value of non-function type 'HTTPURLResponse?'无法调用非函数类型“HTTPURLResponse?”的值
【发布时间】:2016-10-01 21:40:38
【问题描述】:

我正在尝试使用此代码块发出 Alamofire 请求

    request = Alamofire.request(imageURL, method: .get)
                        .validate(contentType: ["image/*"])
                        .response(completionHandler: 

{ (request: URLRequest?, response: HTTPURLResponse?, data: NSData?, error: NSError?) -> Void in

但我将此问题的标题视为运行时错误。

我该如何解决这个问题?

提前谢谢...

【问题讨论】:

    标签: swift3 alamofire


    【解决方案1】:

    alamofire 提供了涉及所有这些参数的 data,而不是单独使用 response、data、error

    解决方案:

    Alamofire.request(imageURL)
             .validate(contentType: ["image/*"])
             .response { data in
    

    我们可以访问数据错误:data.errordata.response

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-16
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 2017-09-02
      • 2017-08-16
      相关资源
      最近更新 更多