In NSTableViewDataSource, the overview says that tableView:objectValueForTableColumn:row:
is "required".
Right next to this, it says that tableView:setObjectValue:forTableColumn:row:
is required for "cell-based tables only", which suggests the person writing this document knew about view-based tables, and that tableView:objectValueForTableColumn:row:
is required for view-based tables.
The documentation for the method tableView:objectValueForTableColumn:row:
itself says:
Note: This method is mandatory unless your application is using Cocoa bindings for providing data to the table view.
but unlike other methods makes no mention of being unnecessary for view-based tables.
And yet, if it is required, I can't figure out what it's used for. If so, what's the relationship between that and -tableView:viewForTableColumn:row:
, which also takes a table, column, and row, and returns the thing to display there?
In some brief testing, it looks like NSTableView will use -tableView:objectValueForTableColumn:row:
if it's defined, and if not, it'll use -tableView:viewForTableColumn:row:
. If they're both defined, it calls them both, but only uses the former for display.
If I'm writing a view-based NSTableView, is there any reason to implement this method?
When something is required, it is necessary to complete an action or achieve a goal. When something is mandatory, it is obligatory, usually because some law or rule imposed it. The difference is that what is required is vital to completing a process, and mandatory is something you must do.
The adjective ‘mandatory’ is derived from the noun ‘mandate’ which means an official command or an authority given by the electorate for a government. In other words, mandatory signifies something which is made obligatory or required by law or rule.
It is important to note that anything that is mandatory has the quality of binding the doer to the work. On the other hand, anything that is compulsory has to be essentially done without postponement.
Examples of mandatory in a Sentence. Adjective. Parents object to the mandatory nature of the shots—and the fact that their child's access to education hinges on compliance with the immunization regulations.
No, despite all of the documentation saying that it is "mandatory" and "required", the NSTableView.h header file says:
This method is required for the "Cell Based" TableView, and is optional for the "View Based" TableView.
If you implement -tableView:viewForTableColumn:row:
to do all the necessary work to display your data, you don't need to implement the other method.
The header file also says why you might implement it for view-based tables:
If implemented in the latter case, the value will be set to the view at a given row/column if the view responds to -setObjectValue: (such as NSControl and NSTableCellView).
This doesn't seem any easier than just implementing it in the normal view-based method, though, so it seems more like an upgrade-compatibility feature than something you'd actually want to use in a new application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With