Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the NSView version of NSTableView -noteNumberOfRowsChanged?

The NSTableView -noteNumberOfRowsChanged documentation says:

Note: When using NSView-based table views this method should be avoided. The table will query the data source for the new number of rows, and properly insert (or remove) rows at the end of the table as necessary with an animation.

Unfortunately, it doesn't say what I should use instead!

I've changed my app from an NSCell-based table to an NSView-based table, in order to use (slightly) more sophisticated custom cells (which are supposedly easier to design/draw as NSViews), but I'm seeing significant performance issues, even on small tables.

I'm already calling -reloadDataForRowIndexes:columnIndexes:, and empirically that is insufficient to get it to re-query -numberOfRowsInTableView (and it gives a range exception trying to draw a row greater than the previously reported number of rows).

Is there a method I should be calling? Or are NSView-based tables simply not meant for performance-critical tables which will frequently have rows added to them?

like image 882
user3404855 Avatar asked Apr 02 '14 16:04

user3404855


1 Answers

Actually,I am still using func noteNumberOfRowsChanged() with NSView-based tableview, it acts perfectly as planned. Without using this method,NSView-based tableview is broken. NSTableView sucks, and its documentation too.

This is how I am using this method for NSView-based NSTableView:

self.pTableView.noteNumberOfRowsChanged()
self.pTableView.reloadData(forRowIndexes: set, columnIndexes: IndexSet.init(integer: 0))
like image 89
Li Fumin Avatar answered Oct 29 '22 14:10

Li Fumin