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