AppDelegate or AppController

岁酱吖の 提交于 2020-01-01 10:02:47

问题


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?


回答1:


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.




回答2:


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).



来源:https://stackoverflow.com/questions/1417105/appdelegate-or-appcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!