Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading NIB file using NSWindowController doesn't set window or top level objects

I have a NIB file that I load using NSWindowController initWindowNibName. The NIB file contains one NSWindow. It's File's Owner is of class NSWindowController. I've connected the window outlet from File's Owner to the Window.

When I load the NIB, [windowController window] is nil and so is the top level objects array. However, I can still call [windowController showWindow:nil] and successfully show the window.

Something just doesn't seem right here. I've confirmed the connections and the File's Owner are OK. Infact, when I look at the _owner value of the windowController instance in the debugger I see it pointing to itself as I expect.

Any suggestions on what might be going on?

Thanks!

like image 301
psychotik Avatar asked May 13 '09 08:05

psychotik


2 Answers

When you say [windowController window] is nil, how are you determining this? The NIB isn't actually loaded until -window is called for the first time. So if you're looking in the debugger you'll see _window as nil until you call showWindow:. After that, _window should have a non-nil value.

like image 54
Rob Napier Avatar answered Oct 11 '22 02:10

Rob Napier


Have you subclassed NSWindowController?

When I do this, I use an NSWindowController called MyWindowController and call initWithWindowNibName: in the subclass's init

And then , set File's Owner to point to the MyWindowController class.

like image 30
Abizern Avatar answered Oct 11 '22 02:10

Abizern