title: Cocoa NSWindowController And NSWindow Not Deallocing
body: <p>I'm working with an NSWindowController to implement a preferences window. Apple's documentation states that by default the controller and window aren't deallocated, because it's useful to not have to reload everything, which makes sense. But their documentation goes on to say that you can override that behavior, but not explain how.</p>
  
  <p>Apple's Docs:</p>
  
  <pre><code>When a window is closed and it is part of a document-based
  application, the document  removes the window’s window
  controller from its list of window controllers. This results 
  in the system deallocating the window controller and the
  window, and possibly the NSDocument object itself. When a
  window controller is not part of a document-based application, 
  closing the window does not by default result in the
  deallocation of the window or window controller. This is the
  desired behavior for a window controller that manages something
  like  an inspector; you shouldn’t have to load the nib file
  again and re-create the objects the  next time the user requests
  the inspector.
  
  If you want the closing of a window to make both
  window and window controller go away when it isn’t
  part of a document, your subclass of NSWindowController
  can observe the NSWindowWillCloseNotification notification
  or, as the window delegate, implement the windowWillClose: method.
  </code></pre>
  
  <p>I can't find anywhere that explains what to "implement" in the windowWillClose: method.</p>
  
  <p>The window controller can be seen here: 
  <a href="https://github.com/gngrwzrd/gwpreferences/blob/master/GWPreferences/GWPreferences/GWPreferences/GWPrefsWindowController.m" rel="nofollow">https://github.com/gngrwzrd/gwpreferences/blob/master/GWPreferences/GWPreferences/GWPreferences/GWPrefsWindowController.m</a></p>
  
  <p>Using the controller can be seen here:
  <a href="https://github.com/gngrwzrd/gwpreferences/blob/master/GWPreferences/GWPreferences/GWAppDelegate.m" rel="nofollow">https://github.com/gngrwzrd/gwpreferences/blob/master/GWPreferences/GWPreferences/GWAppDelegate.m</a> - you can see in this code where I'm trying some bridge casting to try and force release objects but it doesn't work.</p>
  
  <p>So the GWPrefsWindowController.dealloc method never gets called. Any ideas?</p>