An NSTableView
has multiples NSCell
s (indirectly via NSTableColumn
). NSCell follows the Flyweight design pattern; they're cookie-cutters. There's one cell per column and it's asked to draw itself for each row. "Here's a value, draw it on the first row; here's the value for the second row, etc." This is in contrast to view-based tableviews which have a view instance per cell.
I've subclassed NSPopUpButtonCell and for each setXxxValue:
method, I call NSLog();
and forward the message to the super class. The only method which gets called (say, when adding new rows, or otherwise refreshing the table) is setObjectValue:
. This is expected from the documentation... but null
is the only thing passed to it!! It should be passed an NSNumber with the selected item index.
My table draws fine. I'm just trying to understand this because I want to extend/change the behaviour of the cell (obviously as I would'nt have needed a subclass otherwise).
Question: How is this possible? How is the NSPopUpButtonCell being set to a value in order to draw the right value for each row. Even considering bindings, it's NSTableColumn doing the heavy lifting, no? What am I missing?