Usual good practice in Cocoa dictates that each NSView
should have its own NSViewController
as its owner. Should this apply to each row of a View-Based NSTableView
and, if so, what's a good strategy for initializing and caching these NSViewControllers?
Asked
Active
Viewed 524 times
4

FluffulousChimp
- 9,157
- 3
- 35
- 42

Anonymous
- 1,750
- 3
- 16
- 21
1 Answers
2
In most cases this would be overkill. No need for every NSView
to have a controller. What about views which have no relationship with the model layer - in which case a mediator/controller would be unnecessary? In a large table, this would lead to a proliferation of controller objects that are likely unneeded.
I would take a close look at the TableViewPlayground sample project available in the documentation. Notice in that project how Apple uses the various views that comprise the rows. In particular, focus on the ATComplexTableViewController
class and its associated nib file. Here, the dataSource
for the table view returns views for which the dataSource
itself acts as the mediator between the view and the model.

FluffulousChimp
- 9,157
- 3
- 35
- 42