Другим вариантом будет загрузка и кеширование изображения через Kingfisher.Именно так я обычно загружаю изображения в tableView из API.
import Kingfisher
выше вашего класса.
Затем в вашем cellForRowAtIndexPath
установите изображение с помощью Kingfisher.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellID") as! NewMessageCell
let user = users[indexPath.row]
cell.textLabel?.text = user.username
cell.detailTextLabel?.text = user.email
let currentID = Auth.auth().currentUser?.uid
let databaseRef = Database.database().reference().child("users").child(currentID!)
databaseRef.observe(.value) { (data) in
let dictinoray = data.value as? [String: AnyObject]
let profileImage = dictinoray!["profileimage"] as! String
cell.imageView?.kf.setImage(with: URL(string: profileImage))
}
return cell
}
Не уверен, что вы искали альтернативуно это еще один способ сделать это.