views:

369

answers:

4

The problem I've got is that when the preferences window is opened and then closed, it will not open again. Why is this happening and how can this be fixed?

EDIT: Just noticed also I've got the same problem with Main Window.

The window is being opened via the menu bar and is in a separate NIB file.

+3  A: 

Hard to say without seeing the code, but one possibility is that you have "Release When Closed" checked for the window in Interface Builder, and you are loading it once, caching it, then expecting to be able to close and re-open it without loading from the nib again.

smorgan
I un-checked the "Release When Closed" check box, but didn't change anything.
Joshua
+2  A: 

It sounds like you forgot to set the 'window' outlet of your window controller (in the Nib, the File's Owner) to point to your window. Once you connect its 'window' outlet the window controller's showWindow: method will work.

Doug
A: 

I encountered this same problem while working on the chapter 12 (Nib Files and NSWindowController) exercise in Aaron Hillegass's Cocoa Programming for Mac OS X book. Doug's answer above was the solution - I hadn't linked the window outlet of the Preferences.xib's file owner to the window itself (in this case the Panel (Preferences) window).

I right clicked on the "File's Owner" in the Preferences.xib file then left-mouse-button dragged from the Window outlet to the Panel (Preferences). Once done and rebuilt the application worked as intended. I could close and reopen the custom preference panel and my previous settings were still there (since the preference window is not unloaded just hidden).

Thanks Doug!

VancouverDoug
A: 

For any other noobs like me, having this issue :)

Don't forget to set the file's owner class to be the same as the controller class, then you can connect the 'window' outlet to the panel.

Drew