我想设置我的 NSPersistentDocument 对象的窗口的一些属性。我如何访问它?
有没有比这样更好的方法?
[[[[self windowControllers] objectAtIndex:0] window] setBackgroundColor:[NSColor blueColor]];
我想设置我的 NSPersistentDocument 对象的窗口的一些属性。我如何访问它?
有没有比这样更好的方法?
[[[[self windowControllers] objectAtIndex:0] window] setBackgroundColor:[NSColor blueColor]];
不,这是获得它的方法。NSWindowController
负责管理窗口,这就是它拥有窗口的原因。
NSWindowController
如果您正在自定义窗口的外观或行为,那么子类化并将自定义窗口的代码放在该类中实际上会更好,而不是您的NSDocument
/NSPersistentDocument
子类。
NSDocument
(和朋友)旨在管理数据,并NSWindowController
旨在管理 UI。在除了最简单的应用程序之外的所有应用程序中,您都应该继承NSWindowController
.
我正在使用self.windowForSheet
它似乎正在工作。