A common mistake in app development is not setting the correct reuseIdentifier for UITableViewCells, for UICollectionViewCells, or even UITableViewHeaderFooterViews.
For maximum performance, a table viewâ€™Â€Â™s data source should generally reuse UITableViewCell objects when it assigns cells to rows in tableView:cellForRowAtIndexPath:. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse.
What happens if you donâ€™t use a reuseIdentifier?
If you donâ€™t, your table view will configure a brand-new cell each time a row is displayed. This is an expensive operation and will definitely affect the scrolling performance of your app.
Since the introduction of iOS 6, youâ€™re expected to use reuseIdentifiers for header and footer views, as well as UICollectionViewâ€™s cells and supplementary views.
To use reuseIdentifiers, call this method from your data source object when asked to provide a new cell for the table view:
UITableViewCell cell tableView dequeueReusableCellWithIdentifier CellIdentifier forIndexPath indexPath ;
This method dequeues an existing cell if one is available, or creates a new one if necessary using the previously registered nib file or class. If no cell is available for reuse, and you did not register a class or nib file, this method returns nil.Leave a comment