How to change the header in an NSTableView

NSTableViews are a bit more complex than UITableViews, especially in interface builder.

Assuming you have a reference to your table view (let’s say self.tableView) you can access its columns via an array, then replace the string value in the header cell. Here’s how:

First we grab a reference to the column in question (here the last one, but it works with every column of course). Then we set the column’s header cell’s string value to our new title.

The optional line was suggested in an article below, however I found that in Mavericks it’s not needed.

Note that I had no lock referencing the table view in a custom class (which was also its delegate). Instead, I could reference the table view fine in my AppDelegate.

2 thoughts on “How to change the header in an NSTableView

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.