Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is -tableView:objectValueForTableColumn:row: mandatory?

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?

like image 585
user3404855 Avatar asked Mar 25 '14 05:03

user3404855


People also ask

What is the difference between required and mandatory?

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.

What is the root word of mandatory?

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.

What is the difference between mandatory and compulsory work?

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.

How do you use mandatory in a sentence?

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.


Video Answer


1 Answers

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.

like image 111
user3404855 Avatar answered Sep 19 '22 02:09

user3404855