I know that reusing UITableViewCell objects is key to increase UITableView performance.
However I have to simulate a form with a UITableView with grouped cells, where each group is a form section and each cell is a form input (which eventually would push another UIViewController in the navigation stack to enter actual data).
The number of sections and cells are constant and small (no more than 10 cells), and I am trying to access them without having to think in indexPath values. I would like to create cells as controller’s properties, and assign them in cellForRowAtIndexPath method rather than reusing them.
Is this a valid approach in terms of performance? Are there any other scenarios where it’s worth it to avoid reusing UITableViewCell instances?
Thank you!
I think in your case(about 10 items) it’s perfectly reasonable to NOT re-use table view cells. I’ve done it myself once when I had to create some registration form – I’ve just created cells in xib file and returns them from cellForRowAtIndexPath.
It’s not gonna be performance hit as there’s not any heavy calcuation performed. It might be memory consuption problem if your custom cells use some big images(or other memory consuming items). But that’s usually not the case with settings/registration or simple form stuff.
I would go with cell re-use all the time except when you have small tables with custom cells. Personally I do cell re-use even when there’s 3-4 rows if it’s not custom cell.