title: Closing Window and Releasing NSWindowController
body: <p>I have a relatively-lengthy task.  So I bring up a separate window (<strong>NSWindowController</strong>) from <strong>AppDelegate</strong> to show progress.  It goes like</p>
  
  <pre><code>//AppDelegate.m
  if (self.progresswindow == nil) {
      self.progresswindow = [[ProgressController alloc] initWithWindowNibName:@"ProgressController"];
  }
  
  [progresswindow showWindow:self];
  //[[progresswindow window] setReleasedWhenClosed:NO];
  [NSApp runModalForWindow:progresswindow.window];
  </code></pre>
  
  <p>When a task is complete, the progress window will close itself.</p>
  
  <pre><code>//ProgressController.m
  [NSApp stopModal];
  [self close];
  </code></pre>
  
  <p>It works fine.  But when I click on a button to start another session of a task with the same window, the application won't run a task although it opens.  It appears that the last instance hasn't be released.  The progress window has the following lines.</p>
  
  <pre><code>- (void)windowDidLoad {
      NSLog(@"Hey!");
  }
  </code></pre>
  
  <p>And NSLog won't be called for the 2nd time.  I wonder what I'm doing wrong?  Calling <strong>setReleasedWhenClosed</strong> from AppDelegate has no effect.  I have the <strong>Release When Closed</strong> checkbox enabled, anyway.  I read something like I need to observe <strong>NSWindowWillCloseNotification</strong> the progress window in a <a href="https://stackoverflow.com/questions/6538300/cocoa-release-nswindowcontroller">different topic</a> so that I can release it when it closes.  But I'm using <strong>ARC</strong>.  So I can't manually release it, can I?  Meanwhile, if I open Apple's sample (<strong>TableViewPlayground</strong>), it seems that they use this notification.  Furthermore, I've read <a href="https://stackoverflow.com/questions/2648536/how-to-close-a-window-unload-a-nib">this topic</a> and <a href="https://stackoverflow.com/questions/8111790/display-window-again-after-closing-it-and-setting-focus">this topic</a>.  But I don't know what the problem is.</p>
  
  <p>I appreciate any advice.  Thank you for your time.</p>