Skip to content

NSTableView

Ken Harris edited this page Jan 27, 2021 · 2 revisions

Brent Simmons says he doesn't allow autolayout in table cell views. I'm not religious about it, but I do recognize that autolayout is not always the fastest method, and table cells need to be fast. This depends on many factors, like if your table will only ever have 5-10 items, or if it may contain a million items. Autolayout buys you a bunch of functionality by default, like RTL support, which may or may not be important to you.


The clickedRow docs say:

The index of the row the user clicked to trigger an action message. Returns –1 if the user clicked in an area of the table view not occupied by table rows.

However, it can be (as of 10.15) -1 in other cases. Consider:

  1. Take an NSTableView with 2 rows
  2. Select both rows
  3. Select just the 2nd row
  4. Right-click the 2nd row (e.g., to choose a menu)

In a menuitem action, while the selection is changing, clickedRow is -1, even though you only ever clicked on rows. If you set it settle for a second, then clickedRow will again be correct (1).

Clone this wiki locally