NSApplicationDelegate Class Design

I created my first comprehensive OS X application. While working on this, I had some doubts about how I use the class that implements the NSApplicationDelegate protocol (the Xcode class creates the default for Cocoa applications, i.e. MyApplicationAppDelegate.m/h ) .

In many textbooks (and books), I see that people create the AppController class to manage the main or universal tasks of the application. I prefer to add my common tasks directly to MyApplicationAppDelegate and create specific controllers depending on the modules I need to manage.

For example, I add to MyApplicationAppDelegate each MyApplicationAppDelegate used to open other windows (i.e. open the preferences panel), each function that is not strictly associated with a specific module / controller and IBOutlet for the main interface. In MyApplicationAppDelegate I also add every link to the controllers used in my application. This is essentially about it.

I'm really confused because I'm not sure if this is a good design. Does MyApplicationAppDelegate any other purpose?

I would like to receive any suggestions and, if possible, any articles that you may know about design patterns for Cocoa.

+4
source share
1 answer

Xcode is not used to create the application delegation class in the Cocoa default application template.

I believe that Apple only recently introduced the automatic creation of the <AppName>_AppDelegate with their project template, possibly in version 3.2 or so.

That's why in many old books and tutorials you create the AppController class because the old project template did not create it for you.

You can use <AppName>_AppDelegate as the main controller class, and the reason Apple adds it to its template is because many developers use the NSApplicationDelegate object as the main application controller.

A great resource to learn more about design patterns in Cocoa is a book called Cocoa Design Patterns .

+1
source

All Articles