Easiest way

suggest change

A simple way to do this is Alamofire with the AlamofireImage UIImageView extension. The table cell needs an image view named imageView.

In tableView(_:cellForRowAt:), download the image like this. UIImage(named:) is optional. The ! crashes when placeholder is not in the asset catalog. If the cell is reused before the download finishes, this call can still set the image on the reused cell.

let url = URL(string: "https://httpbin.org/image/png")!
let placeholderImage = UIImage(named: "placeholder")!

imageView.af_setImage(withURL: url, placeholderImage: placeholderImage)

url is the image to download, and the placeholder is an image already in the app. af_setImage shows the placeholder during the download and replaces it when the image arrives.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents