I have an iPad application that is being backed by Core Date and displaying data in a UITableView. I am also using custom cells to display multiple ULabels per cell.
It works fine but when a lot of items are added to the tableView it bogs down and feels kind of sluggish. I am not currently using the NSFetchedResultsController. Whenever a change is made to the data, an ivar array’s data is refreshed like this:
items = [self.managedObjectContext executeFetchRequest:allItems error:&error];
Items is the array the tableView pulls all of its data from and everything updates and works. But it isn’t super fast! Is there a problem with my approach? Is the NSFetchedResultsController the only way to go? The processing going on in the delegate/data source methods isn’t that heavy. Basically pulling out values from the array and setting them to UILabels.
Everything works the way I need it to right now, I just need it to be more responsive.
Thanks
NSFetchedResultsControlleris definitely highly recommended. It could not only potentially address your performance problem, but will also lead to all kinds of convenient facilities (such as the delegate protocol) and behind the scenes optimizations.The most important of these optimizations would perhaps be memory management. Your solution (with all items in an array) appears to be a poor design choice and will not scale to a large amount of records / rows.
That being said, use the usual optimization strategies when drawing cells:
If performance is still an issue, you will have to draw your content yourself by overriding the
drawRectofUITableViewCellsubclass.