title: NSMutableArray as an Instance Variable
body: <p>I have a instance variable which is a NSMutableArray</p>
  
  <pre><code>@interface SummaryWindowController : NSWindowController {
  
      NSMutableArray *aBuffer;
  </code></pre>
  
  <p>The NSMutableArray is set using this method (called from the object that init'ed this object):</p>
  
  <pre><code>- (void)setGlobalStatusArray:(NSMutableArray *)myArray
  {
      if (!aBuffer) {
          [myArray retain];
          NSLog(@"aBuffer not init , alloc init now");
          aBuffer = [[NSMutableArray alloc] initWithArray:myArray];
      }
      NSLog(@"--&gt; Received buffer: %@",aBuffer);
  
  }
  </code></pre>
  
  <p>The NSLog shows the contents of the array when that method runs:</p>
  
  <pre><code>2011-08-18 16:00:26.052 AppName[74751:1307] --&gt; Recievied buffer: (
          {
          discription = DiskUsage;
          menu = "&lt;NSMenuItem: 0x1005116e0 Hardware Status&gt;";
          status = Warning;
      },
  </code></pre>
  
  <p>But in my method that uses this instance variable it no longer seems init'ed</p>
  
  <pre><code>- (IBAction)refreshButtonClicked:(id)sender
  {
      NSLog(@"The user has clicked the update button");
      if (!aBuffer) {
          NSLog(@"refresh button not init");
      }
      NSLog(@"Buffer is currently:%@",aBuffer);
  }
  </code></pre>
  
  <p>As when it gets to this point I see the following NSLog:</p>
  
  <pre><code>2011-08-18 16:04:25.301 AppName[74829:1307] The user has clicked the update button
  2011-08-18 16:04:25.303 AppName[74829:1307] refresh button not init
  2011-08-18 16:04:25.304 AppName[74829:1307] Buffer is currently:(null)
  </code></pre>
  
  <p>Which would indicate to me that aBuffer has been (auto?)released?</p>
  
  <p>Any ideas why this would be doing this? I thought at first I had two distinct objects, one which I created by initing NSWindowController from the original controller:</p>
  
  <pre><code>   @interface AppName_AppDelegate : NSObject 
      NSMutableArray *globalStatusArray;
  
      @implementation AppName_AppDelegate
  
      if ( summaryWindow ) {
              [summaryWindow release];
          } // end if
          summaryWindow   = [[SummaryWindowController alloc] initWithWindowNibName:@"SummaryWindow" owner:globalStatusController];
      [summaryWindow showWindow:self];
      [summaryWindow setGlobalStatusArray:globalStatusArray];
  </code></pre>
  
  <p>And one that was created when the nib load, identical but different objects however I now don't think thats the case as I don't see duplicate NSLogs any more, so I assume its just some basic memory issue with NSMutableArray(s)?</p>