A cell, no matter if a table view cell or collection view cell, has three recommended functions. 

  • awakeFromNib: it is automatically called when the cell and its view are initialized and loaded.
  • prepareForReuse: as you scroll through a collection view or a table view, instead of creating new cells, the table-collection view simply reuses the ones that disappeared through. That may result sometimes to a cell presenting old data. That can be resolved through the prepareForReuse. In the prepareForReuse "reset" the display of your data. 
  • setSelected:animated: is automatically called each time the cell was selected or deselected.
Did this answer your question?