I’m curious just how expensive in as far as resources go is UITableView’s reloadData? I have an app which will make roughly 10 subsequent HTTP requests, and as it gets data / preps, it reloads the tableView. As the data set grows larger and larger, it’s becoming very sluggish. I’m trying to figure out if it’s because of the amount of times I’m reloading the tableView or because of how I’m grabbing/parsing the data.
What’s the best practice in this case?
The best practice is to have your implementation of
cellForRowAtIndexPath:do as little work as possible. In fact, it really shouldn’t be doing any work except populating theUITableViewCellinstance with the data it needs to display.You should be using cached
UITableViewCells so you don’t have to allocate a new cell each time. If you can do your parsing and such in a separate thread and make the parsed data, ready to present, accessible tocellForRowAtIndexPath:, you shouldn’t have any performance problems.You didn’t say if you were using a custom
UITableViewCellsubclass, but if you are, deep view hierarchies can also present a performance problem, since each view in the hierarchy gets drawn. The flatter you can makeUITableViewCells, the better.Hope that gets you moving in the right direction.