我遇到了麻烦。查看以下代码部分:
// Create a datatask and pass in the request
let dataTask = session.dataTask(with: request, completionHandler: { (data:NSData?, response:URLResponse?, error:Error?) in
// Get a reference to the image view element of the cell
let imageView = cell.viewWithTag(1) as! UIImageView
// Create an image onject from the data and assign it into the ImageView
imageView.image = UIImage(data: data!)
})
我该如何解决这个问题?提前谢谢!
答案 0 :(得分:0)
由于一些评论,我有一个答案!我更改了"请求"从NSURLRequest到URLRequest,我还将代码更新为:
// Create a datatask and pass in the request
let dataTask = session.dataTask(with: request, completionHandler: { (data, response, error) in
// Get a reference to the image view element of the cell
let imageView = cell.viewWithTag(1) as! UIImageView
// Create an image onject from the data and assign it into the ImageView
imageView.image = UIImage(data: data!)
})