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.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

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

Leave a Reply to Jay Versluis Cancel reply

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