I have an instance of a view-based NSTableView containing one column. I need to determine the instance of NSTableCellView for that column prior to the table being populated. I need the view to determine its height and the font it uses for the text field it contains.
I have tried
func view(atColumn: Int, row: Int, makeIfNecessary: Bool) -> NSView?
but it crashes because the empty table contains no rows.
I have tried using an identifier for the cell and called
func makeView(withIdentifier: NSUserInterfaceItemIdentifier, owner: Any?) -> NSView?
but the table displays no data after providing the identifier in the xib. I think that this may have something to do with the table being bound to an array controller.
Since, when constructing the table in IB, one creates instances of NSTableCellView in the NSTableColumns, I would have thought there would be a means of querying the column for the views, but it doesn't appear to be so.
Any guidance would be greatly appreciated.
From makeView(withIdentifier:owner:):
Note that a cell view’s identifier must be the same as its table column’s identifier for bindings to work. If you’re using bindings, it’s recommended that you use the Automatic identifier setting in Interface Builder.
Use the identifier of the table column in makeView(withIdentifier:owner:)
or use the same identifier for the table column and the cell view.