阐明窗口控制器的使用

发布于 2025-01-04 22:33:57 字数 146 浏览 1 评论 0原文

我一直在学习何时使用 WindowController 以及何时将内容放入 Document 对象中。看起来如果你有一个简单的界面,文档可以作为控制器很好地工作。我的应用程序中有一个简单的界面,但是将 IB 出口放入 WC 是一个好的做法吗?当您不想使用卫生间时会出现什么情况?

I've been learning about when to use WindowController and when to put stuff in the Document object. Looks like Document can work fine as a Controller if you have a simple interface. I have a simple interface in my application, but is it a good practice to put IB outlets into WC anyway? What would be a scenario when you would NOT want to use a WC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和我恋爱吧 2025-01-11 22:33:57

以下是一些场景:

  1. 您打算与多个窗口一起使用的文档对象(如上面评论者所述)或具有不同的视图
  2. 您可能会在不显示窗口的情况下打开和处理文档对象
  3. 具有如此多控制器代码的应用程序,这很困难使用单个类进行管理

在窗口初始化期间,文档将实例化窗口控制器。

发生这种情况后,分离模型控制器和视图控制器的部分目的是删除文档对窗口的依赖

在完善设计时,请查看文档需要访问窗口的位置,并考虑是否可以以不同的方式实现该功能,例如,通过在窗口控制器而不是文档中处理它。

Here are some scenarios:

  1. A document object you intend to use with multiple windows (as commenter noted above) or having different views
  2. A document object you could potentially open and process without displaying a window at all
  3. An application with so much controller code that it's difficult to manage with a single class

During window initialization, the the document will instantiate the window controller.

After that happens, part of the point of separating the model controller and view controller is removing the document's dependency on the window.

As you refine your design, take a look at places where the document needs access to the window, and consider whether you can implement that functionality a different way, for example, by handling it in the window controller instead of the document.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文