Cocoa中单个窗口中的多个文档 [英] Multiple Documents in a Single Window in Cocoa

查看:145
本文介绍了Cocoa中单个窗口中的多个文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过一个标签界面在一个窗口中编写一个可能有多个文档的应用程序。我应该避免NSDocument架构(基于Cocoa基于文档的应用程序模板)吗?据我所知,它只支持一个或多个窗口每个文档,但不是反过来。

I want to write an application which may have multiple documents in a single window via a tabbed interface. Should I avoid the NSDocument architecture (the Cocoa Document-based Application template)? As far as I can tell, it supports only one or more window per document but not vice versa.

我已经摔了这个问题了一段时间,我的许多应用程序在NSDocument架构,但我不能找出一个好的方法来关联多个文档与一个单一的窗口。

I have been wrestling with this question for a while and have already built much of my application on the NSDocument architecture but I cannot figure out a good way to associate multiple documents with a single window.

编辑:我想有项目文档窗口除了基本文档窗口。在这种复杂性的水平,仍然值得黑客NSDocument架构?苹果是否使用NSDocument架构编写Xcode(这样工作)?

I want to have project document windows in addition to basic document windows. At this level of complexity, would it still be worth hacking the NSDocument architecture? Did Apple write Xcode (which works this way) using the NSDocument architecture?

推荐答案

我尝试将NSDocument应用程序几年前的标签界面,并结束了这么失望几个月后,我回去,重构文档架构件。这不是不可能的,但你最终会解决这么多的问题,最终的结果几乎不像一个正确的NSDocument应用程序。最好只是重写你需要的位,而不是最终得到大量的代码只是颠覆Cocoa框架。

I tried shoehorning an NSDocument app into a single window tabbed interface a few years ago, and ended up so frustrated after a few months I went back and refactored out the document architecture pieces. It's not impossible, but you end up working around so many problems that the final result barely resembles a proper NSDocument app. It's better to just rewrite the bits you do need, than end up with a lot of code just to subvert the Cocoa frameworks.

这篇关于Cocoa中单个窗口中的多个文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆