How to close a window (unload a NIB)?

bastibe picture bastibe · Apr 15, 2010 · Viewed 7.4k times · Source

I have a custom NSWindowController subclass that loads a NIB file during initialization like this:

self = [super initWithNibNamed:@"myNib"];
if (self != nil) {
    [self window];
}

The nib contains some custom views and some other controls. The NSWindowController is the file's owner and at least one of the views even binds to it.

Simply, what do I have to do to close and release that window? I spend the whole day trying to figure that out and I am still clueless.

Answer

John Ballinger picture John Ballinger · Jul 22, 2010

Thanks @peter hosey.

[self close]; // will work only if your nib is wired up correctly.

Open the nib for your file. On the Window you need to wire the "Referencing Outlet" of the window to the "Files Owner" and choose Window. Otherwise nothing will work.