NOTE: Andrew's response caused me to take yet another look. This feature is buried deep in a large application which has in internal timer. If that timer is off I get the wrong behavior described here. If the timer is on things work as expected. I don't know why that timer interacts with this table view, but, as I said, it's a large, complex app.
I want the user to be able to select which columns to show. He'll be presented with a set of radio buttons or check boxes, one for each key in the object being displayed. He can check or uncheck a box, and the NSTableView will add or delete a column for that key.
The object being displayed is an NSDictionary. The keys of the dictionary are not known until runtime, so I have to create columns with identifiers at runtime... they are not known at compile time.
Implementing the add functionality went smoothly. I create a column and a header cell, setting the text of the header cell to some value. But the delete is not being so easy. [myTableView removeTableColumn:col]
deletes the column, but does not deal with the header so nicely. Sometimes the header text is not removed. Sometimes the header text in two columns is removed. Sometimes I end up with two header text strings printed on top of each other.
Clearly I'm missing something. How does one programmatically remove a column and its header?