title: Converting self-releasing objects to ARC
body: <p>OK, so Apple brought ARC to us, which is great. After refactoring my Application to ARC almost everything works fine and it is a lot easier now to develop and maintain.</p>
  
  <p>There is just one problem I still can't figure out.</p>
  
  <p>My job management program shows different detail information of proposals, orders and so on in their own windows. So I have a special class where WindowControllers gets allocated and initiated with initWithWindowNibName and then the window is shown with showWindow:</p>
  
  <pre><code>DetailWindowController *proposalWindowController = [[DetailWindowController alloc] initWithWindowNibName:@"ThePorposalWindow"];
  [proposalWindowController showWindow:nil];
  </code></pre>
  
  <p>Before ARC the Instance of the WindowController did the release like shown in the <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/WinPanel/Concepts/UsingWindowController.html#//apple_ref/doc/uid/20000225-BAJCCIFJ" rel="nofollow noreferrer">documentation</a>:</p>
  
  <pre><code>- (void)windowWillClose:(NSNotification *)notification
  {
     [self autorelease];
  }
  </code></pre>
  
  <p>But now with ARC this is not possible anymore and what makes it even worse, in my special class where the WindowController is allocated and initiated, the same windowController is released by ARC because there is no pointer to the windowController.</p>
  
  <p>My idea was to copy the windowController into an mutuable array:</p>
  
  <pre><code>[proposalWindowArray addObject:proposalWindowController];
  [[proposalWindowArray lastObject] showWindow:nil];
  </code></pre>
  
  <p>And in the windowControllers delegate method windowWillClose I post a notification to my special class:</p>
  
  <pre><code>- (void)windowWillClose:(NSNotification *)notification
  {
      [[NSNotificationCenter defaultCenter] postNotificationName:@"ProposalWindowWillClose" object:[[self window] windowController] userInfo:nil];
  }
  </code></pre>
  
  <p>In my special class I listen to the notification and remove the object from the array:</p>
  
  <pre><code>- (void) proposalWindowWasClosed: (NSNotification *) notification
  {
      [proposalWindowArray removeObjectIdenticalTo:[notification object]];
  }
  </code></pre>
  
  <p>It works, but I still do not believe that this is the correct way.</p>
  
  <p>Does anybody has the same problem or a tip to make it better?</p>