I am using AlamofireImages to try to download an image from a server and display it in my table view cell, this is what I got, but my images does not appear, just the textLabel
This helped me:
Create this function first to help pull down the image. If you're pulling multiple images, you may want to create a new swift file and make this static or just call it in the file that you need it. This way you can refer to it instead of re-writing code:
static func loadImage(_ imageView: UIImageView,_ urlString: String) {
let imgURL: URL = URL(string: urlString)!
URLSession.shared.dataTask(with: imgURL) { (data, respond, error) in
guard let data = data, error == nil else { return}
DispatchQueue.main.async (execute: {
imageView.image = UIImage(data: data)
})
}.resume()
}
Then to pull down the info:
if let logoName = variable.logo {
StaticFileName.loadImage(cell.imgVariableInCell, "\(logoName)")
}
return cell
}
Then you're good to go.