【发布时间】:2011-08-08 16:33:12
【问题描述】:
我很难理解出了什么问题。我有一个带有 NSWindow 和 NSTextView 的 NSWindowController。我想将 NSWindowController 和 NSWindow(连同它的所有控件)归档到一个文件中。
然后,我想取消归档相同的 NSWindowController 和 NSWindow 以及文件中的所有视图。但苹果文档说:
Note: Although the NSWindow class inherits the NSCoding protocol from NSResponder, the class does not support coding. Legacy support for archivers exists but its use is deprecated and may not work. Any attempt to archive or unarchive an NSWindow object using a keyed coding object raises an NSInvalidArgumentException exception.
重要的是,如果我 encodeWithObject:windowController,这不会存储 NSWindow。因此,当我为 windowController 进行 decodeWithObject 时,没有加载 NSWindow。
如何归档/取消归档 NSWindowController / NSWindow 及其所有控件?我错过了什么?
【问题讨论】:
-
这不正常。您归档应用程序的控制器和视图部分的目的是什么?可能有更好的方法来实现您的目标。
-
基本上我正在实施保存文档的情况。我想保存窗口控制器,因为它包含控制器的内部状态。我正在尝试保存 nswindow,因为它有自己的文本字段、自定义视图等内部状态。我知道我做错了什么,只是似乎无法弄清楚该怎么做/如何去做。跨度>
标签: objective-c xcode4 interface-builder nswindow nswindowcontroller