单窗口、非基于文档的应用程序中的 Nib 文件(和代码)组织
StackOverflow 的好心人,
我正处于构建非基于文档的 Cocoa 应用程序的早期阶段。我的目标是类似于 iTunes 的窗口布局,有左、中、右窗格。此类应用程序的 Xcode 模板包括一个名为 MainMenu.xib 的文件,其中包含主菜单和主应用程序窗口,以及 MyApp_AppDelegate 类中包含的支持逻辑。
我已经可以预见,继续沿着这条路线走下去最终将导致一个非常大且无组织的应用程序委托类。因此,我的敏锐直觉告诉我将主窗口的逻辑分解为它自己的 NSWindowController 子类(以及随附的 XIB 文件)。此外,我将每个窗格拆分为自己的 NSViewController 子类是否正确?这似乎可以更好地分离我的关注点,但代价是更多的文件和一些额外的代码将所有内容连接在一起。
我能找到的最接近的建议是苹果的 Interface Builder 用户指南,但它没有直接回答问题。但是,我想我的问题不是特别关于 nib 文件,而是关于高级应用程序组织。
Good people of StackOverflow,
I am in the early stages of building a non-document-based Cocoa application. What I'm aiming for is a window layout similar to iTunes, with a left, middle, and right pane. The Xcode template for such an application includes a file called MainMenu.xib containing both the main menu, and the main application window, with supporting logic contained in the MyApp_AppDelegate class.
I can already foresee that continuing down this route will eventually lead to a very large and disorganized app delegate class. Therefore, my spidey sense tells me to break out the logic for the main window into its own NSWindowController subclass (and accompanying XIB file). Furthermore, would I be correct to split out each pane into its own NSViewController subclass? This would seem to better separate my concerns, at the expense of more files and some extra code to wire everything together.
The closest advice I've been able to find is in Apple's Interface Builder User Guide but it does not answer the question directly. However, I guess my question is not about nib files in particular, but about high-level application organization.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论