2011-10-07 67 views
1

我想设置我的NSPersistentDocument对象的窗口的一些属性。我如何访问它?NSPersistentDocument - 如何访问窗口?

有没有比这样更好的方法?

[[[[self windowControllers] objectAtIndex:0] window] setBackgroundColor:[NSColor blueColor]]; 

回答

3

不,这是得到它的方法。 NSWindowController负责管理窗口,这就是它拥有窗口的原因。

如果您自定义窗口外观和行为,它实际上是更好的继承NSWindowController并把代码中的自定义窗口在类,而不是你的NSDocument/NSPersistentDocument子类。

NSDocument(和朋友)是为了管理数据,并且NSWindowController是为了管理UI。除最简单的应用程序外,您应该继续使用NSWindowController

+0

好的,谢谢;-)我会这么做! – tamasgal

1

我正在使用self.windowForSheet这似乎是工作。