I am settiing an image onto a tableViewCell
with Alamofire
let messageImage = cell?.viewWithTag(6) as! UIImageView
messageImage.image = nil
messageImage.af_setImage(withURL: photoUrl! as URL)
return cell
I am appending each cell item to an array using Firebase
:
ref.child("messages").child(ticker.current).queryOrderedByKey().observe(.childAdded, with: {snapshot in
let snapDict = snapshot.value as? NSDictionary
let photoUrl = snapDict?["photo_url"] as? String ?? ""
messageArray.insert(messageCellStruct(photoUrl: photoUrl), at: 0)
})
Then I am updating the image on the Same Exact URL with FirebaseStorage
When I re-call the cell ViewController
that the TableViewCell
is in, the image is not changed on the first couple of cells. But as I scroll to older cells the image is updated:
messageArray.removeAll()
tableView.reload()
If I rebuild the app all cell images are how they are supposed to be.
I am assuming this is because of an Observer error or Im not removing the observer. I really dont know.
1.) The cells share the same exact URL im just changing the data.
2.) It seems to be only working when a cell hasnt loaded yet(or been assigned).
3.) It works perfectly fine after I rebuild and run the app.
Maybe I need to clear the Alamofire cach?