获取 NSDocument 的 readFromData::: 的正确窗口
我已经在我的 Cocoa 应用程序中成功实现了 NSDocument 类,它也能够正确保存数据。但在打开文件时我遇到了问题。
这是我的基本设置:
NSDocument MyFile ==xib File=> MyFile.xib
NSObject FileClass 作为处理类
FileClass 是一个压缩/解压缩文件的类,并连接到 MyFile.xib 中窗口的文本字段。保存是通过默认的 NSNotificationCenter 完成的。数据需要在此类中进行处理,因为它不包含原始 NSString。
假设我有三个需要打开的文档 我有三个 NSDocument 实例,它们现在通过 NSNotificationsCenter 发送数据。因为我有三个 NSDocument,所以我有三个窗口和三个 FileClass 实例。现在,如果正确的 FileClass 接收到数据就只是运气了,因为我无法过滤接收到的数据是否建议用于此窗口。现在,随机 FileClass 处理该文件并设置其关联文本视图的文本。因此窗口 1 可以显示窗口 3 中应该显示的数据。
数据流:
NSDocument =>从数据读取=> NSNotificationCenter =>;随机文件类 =>关联的 TextView。
缩小范围:如何将数据路由到正确的窗口以及如何/在何处在此构造中包含 FileClass?
提前致谢!
保罗
I've successfully implemented a NSDocument class in my Cocoa App which is also able to save data properly. But I have problems when it's about opening files.
This is my basic setup:
NSDocument MyFile ==xib File=> MyFile.xib
NSObject FileClass as processing class
FileClass is a class that compresses/decompresses files and is connected to the window's textfield in MyFile.xib. Saving is done via the default NSNotificationCenter. The data needs to be processed in this class because it does not contain raw NSStrings.
Let's say I have three documents that need to opened I have three NSDocument instances that now send their data via the NSNotificationsCenter. Because I have three NSDocuments I have three windows and three FileClass instances. Now it's just luck if the correct FileClass receives the data because I have no possibility to filter whether the received data is proposed for this window. A random FileClass now processes the file and sets the text of its associated Text View. So Window 1 could show the data that were thought to be shown in Window 3.
The data flow:
NSDocument => readFromData => NSNotificationCenter => random FileClass => associated TextView.
To narrow it down: How do I route the data to its correct window and how/where do I include FileClass in this construct?
Thanks in advance!
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您必须强制文档数据通过通知中心到达您的查看类,则这表明存在重大设计缺陷。为什么你必须这样做?您试图规避哪些问题?
It's an indication for a major design flaw if you have to force your document data through the notification center to your viewing classes. Why do you have to do that? What issues are you trying to circumvent?