Swift 4 Error: "Cannot convert value of type 'URLRequest' to expected argument type 'URL!'"

Swift 4 Error: "Cannot convert value of type 'URLRequest' to expected argument type 'URL!'"

正如标题所说。我收到此错误,但不确定这是否与 Swift 4 转换有关。我一直在尝试解决代码,但还没有运气,所以决定把这个问题抛给 SO。在线引发此错误:"cell.businessPostImage.setImageWith(postRequest,"。谢谢。

cell.businessPostImage.image = nil
        if let postURL = URL(string: downloadURL) {
            let postRequest = URLRequest(url: postURL)
            cell.businessPostImage.setImageWith(postRequest, placeholderImage: nil, options:
            { (imageRequest, imageResponse, image) in
                    cell.businessPostImage.contentMode = UIViewContentMode.scaleToFill
                    cell.businessPostImage.image = image
            }, completed: { (imageRequest, imageResponse, error) -> Void in
                // failure downloading image
                print("Error downloading Firebase post image")
                print(error)
            })
        }

你必须这样使用:

if let postURL = URL(string: downloadURL) {
    let postRequest = URLRequest(url: postURL)
    cell.businessPostImage.setImageWith(postURL, placeholderImage: nil, options: SDWebImageOptions.ProgressiveDownload, completed: { (imageRequest, imageResponse, error) -> Void in
        // failure downloading image
        print("Error downloading Firebase post image")
        print(error)
    })
}