Instance Method

prepareForReuse()

Performs any clean up necessary to prepare the view for use again.

Declaration

func prepareForReuse()

Discussion

The default implementation of this method does nothing. However, when overriding this method, it is recommended that you call super anyway. Subclasses such as UICollectionViewCell override this method and use it to perform relevant actions. So if your subclass descends from UICollectionViewCell or some other intermediate class, calling super ensures that your class gets the parent’s behavior.

When a view is dequeued for use, this method is called before the corresponding dequeue method returns the view to your code. Subclasses can override this method and use it to reset properties to their default values and generally make the view ready to use again. You should not use this method to assign any new data to the view. That is the responsibility of your data source object.

See Also

Reusing Cells

var reuseIdentifier: String?

A string that identifies the purpose of the view.