Fixing -[NSTableView setEnabled:] for view-based tables
View-based NSTableView that was introduced with Mac OS X 10.7 brought a long sought relieve to platform developers. Yet ever since its behavior was somewhat surprising and documented. One such quirk is the isEnabled
status of a view-based table view.
Being a subclass of NSControl
the table inherits the isEnabled/setEnabled:
family of methods. In the old era of NSCell
status’s change would be forwarded to every cell of every column: that’s because NSCell
provides a monstrous interface which also includes these methods.
Contrary, NSView
does not support it and thus setEnabled:
has no effect on view-based tables. To circumvent it every subview whose state needs to be adjusted must be configured explicitly (either directly or via Cocoa bindings).
And here is another quirk: bindings of views inside the table must target their enclosing cell view and nothing else. Any other target such as NSUserDefaultsController
or a subclass of NSObjectController
will cause the binding to be silently dropped and reset to nil.
I have filed a bug report and documentation improvement feedback, but doubt highly they ever will get addressed. It’s been almost 10 years after all.