PDA

View Full Version : Opening a Window




Duke Leto
Jun 24, 2009, 08:19 PM
I want the user to be able to open a window from another xib file by clicking a button. I created an NSWindowController subclass. It has an open: action connected to the button, its window is connected to the window, and it is the File Owner of the xib containing the window. The open: method calls loadWindow and showWindow:, but the window does not appear.

The problem appears to be that the window variable shows up as 0x0. Why is it nil, and how can I fix it?

P.S.
I know that I have been using this forum as a crutch for what I do not know about development. Please bear with me, as I am coming from iPhone programming - where I insisted on programmatically creating interfaces.



kainjow
Jun 24, 2009, 08:20 PM
How are you initializing the window controller in code? Are you passing it the correct nib name? Oh, and don't call loadWindow (see the docs). You just need to init the controller with the right nib name, and call showWindow:

Duke Leto
Jun 24, 2009, 08:24 PM
Ooh... you mean to say that Cocoa doesn't magically initialize things after all?

I should have known that Keebler elves weren't magically fixing my code!

Thanks!