"Cocoa Design Patterns" Chapter 29, "Controllers," contains an MVC solution to exactly the problem Oleg Krupnov describes. The chapter presents a relatively simple MVC MYShapeDraw application. The chapter leads the reader through the step by step process of re-inventing NSArrayController as part of the MYShapeDraw application. The goal is to highlight the rationale and use pattern for array controller and other controllers. One of the reasons to use an array controller as a mediator between model objects and views is precisely so that it's easy to have multiple different views and potentially different models. Therefore, the application provides multiple views. The example even discusses sharing selection information by multiple views or letting each view have a different notion of the current selection.

The application also uses the "Associative Storage" pattern from chapter 19 to enable any view to store whatever extra information it wants along with model objects. Categories are used to separate view related code from the model code. Apple uses this approach in several places to add view layer capabilities to model layer objects. See NSString and NSStringAdditions.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to