它给了我错误:无法调用非函数类型“HTTPURLResponse?”的值?它应该是由@escaping 引起的,但我无法在下面的句子中使它起作用。请帮助,Swift 3.0,AlamofireImage。还有其他类似的答案,但不能使它们与我下面的代码一起使用。
func getNetworkImage(_ urlString: String, completion: @escaping ((UIImage) -> Void)) -> (ImageRequest) {
let queue = decoder.queue.underlyingQueue
let request = Alamofire.request(urlString)
let imageRequest = ImageRequest(request: request)
imageRequest.request.response(
queue: queue,
responseSerializer: Request.imageResponseSerializer(),
completionHandler: { response in
guard let image = response.result.value else {
return
}
let decodeOperation = self.decodeImage(image) { image in
completion(image)
self.cacheImage(image, urlString: urlString)
}
imageRequest.decodeOperation = decodeOperation
}
)
return imageRequest
}