On May 28, 2013, at 7:15 AM, Quincey Morris 
<quinceymor...@rivergatesoftware.com> wrote:
> In the broadest MVC terms, the "C" is often a NSWindowController subclass. 
> The "M" is often the app delegate *or* a NSDocument subclass, or is a more 
> specialized object graph to which the app delegate or document holds a 
> reference. The "V" is the window and its contained views.

 While it is true that many people use the app delegate as the model (aka a 
hidden singleton that is a dump for all sorts of stuff), I wouldn't recommend 
that.

 The app delegate is intended to provide behaviours for the application as 
shown in the Dock and Finder, and a root for global properties and actions 
exposed to AppleScript and other automation/scripting/interapplication 
communication mechanisms. If you have anything else, you should create a 
separate (often reusable) class that the application or application delegate 
creates.

 For document-based apps, NSApplication already does that by default, but you 
can modify the behaviour. For shoebox apps and the likes, you create an 
NSWindowController that implements the main window, and maybe another one for a 
preferences window. But only create them, keep their specific code out of the 
application and app delegate as much as possible. Otherwise your app delegate 
grows into a huge god-object and needs to be recompiled every time one of the 
other classes is changed even slightly, and worse, may cause all other files in 
your project to recompile every time you change it to adjust a method another 
object uses from it.

 In particular, only few menu items should be implemented by the application 
itself. Instead, most of them should be hooked up to the First Responder, where 
each window controller can then claim it using the responder chain when it is 
frontmost.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to