I have an NSTableView with 5 columns, each of which contains a stock of NSTableCellView in nib. (Stock cells have a text box and an additional image.) When populated, the table has about 50 rows. Everything looks fine, but the scroll performance is pretty poor. This seems to be happening because each cell receives a drawRect: message for its full rect whenever the table scrolls. However, neither reloadData nor reloadDataForRowIndexes: ColumnIndexes: is called, so this is not the case. This is not the contents of the cells: I tried to comment on all my code to just leave the default cell image and text for each cell, and the performance is the same. When scrolling, none of the cells is updated. (I set a breakpoint in tableView: viewForTableColumn: row: to make sure.)
My implementation has the following delegation methods:
- tableView: viewForTableColumn: string: in the delegate; this creates and populates new cells through makeViewWithIdentifier: owner:
- numberOfRowsInTableView: in the data source; it returns a constant number
- tableView: sortDescriptorsDidChange: in data source
What is it! Not very difficult, though.
I feel like something is completely obvious to me. What can cause these redraws?
EDIT:. Think about it, some other applications (uTorrent, Xcode) seem to exhibit the same slow scroll behavior. You can really see this if you look at CPU usage while scrolling. Activity Monitor, on the other hand, has an oily, smooth scrolling that hardly touches the processor. How to get this in my application?
EDIT 2: I think I found my mistake. According to Apple :
In iOS applications, Core Animation is always turned on and supported by each view layer. In OS X, applications must explicitly enable Core Animation by following these steps:
Enabling layer support in one of the previous ways creates layer support. With a view with layer support, the system takes responsibility for creating the lower layer object and for updating this layer. In OS X, it is also possible to create that your application actually creates and manages a lower layer object. (You cannot create layer-level views in iOS.) For more information on how to create layer-level views, see "Layer Hosting allows you to change the layer object in OS X".
I will add an answer as soon as I fix my performance issues. With a quick skip, my scrolling is still bumpy, but my CPU usage has dropped from 70% to 10% when scrolling.