selectionDidChange

I’ve just discovered an unwelcome difference between

func tableViewSelectionDidChange(_ notification: Notification)
and
func outlineViewSelectionDidChange(_ notification: Notification)

(NSOutlineView inherits from NSTableView, and the protocols share a lot of similarities).

When there is no valid selection in an NSOutlineView, outlineviewSelectionDidChange fires, and outlineView.selectedRow is -1.

When there is no valid selection in an NSTableView, tableViewSelectionDidChange does not fire (although tableView.selectedRow is still -1.

This is sub-optimal. In my case, I wanted to enable a ‘remove’ button whenever an item is selected, and disable it when the table has no selection – instead of doing this in selectionDidChange, I also have to call it after removing an item, which makes my code just that little bit messier.