AppDelegate or AppController

2019-03-29 04:58发布

While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and some AppController for defining IBActions that open various windows that use subclasses of NSWindowController.

Is there some sort of rule of thumb for this?

2条回答
Explosion°爆炸
2楼-- · 2019-03-29 05:45

It's just a class name. AppDelegate implies that the class's main duty is as NSApplication's delegate, whereas AppController seems to imply a broader range of responsibility.

查看更多
甜甜的少女心
3楼-- · 2019-03-29 05:47

I create one class that is solely my app delegate, and instantiates my main controller (in applicationWillFinishLaunching:) and releases it (in applicationWillTerminate:). Then I have two classes with clearly-defined responsibilities: My main controller is the owner of the main window and the model, and the app delegate is nothing but the app delegate (and, as part of these duties, the owner of the main controller).

查看更多
登录 后发表回答