title: Use autorelease before adding objects to a collection?
body: <p>I have been looking through the questions asked on StackOverflow, but there are so many about memory management in Objective-C that I couldn't find the answer I was looking for.</p>
  
  <p>The question is if it is ok (and recommnded) to call autorelease before adding a newly created object to a collection (like NSMutableArray)? Or should I release it explicitly after adding it. (I know NSMutableArray willl retain the object)</p>
  
  <p>This illustrates my question:</p>
  
  <p><strong><em>Scenario A (autorelease):</em></strong></p>
  
  <pre><code>- (void) add {
     // array is an instance of NSMutableArray
  
     MyClass *obj = [[[MyClass alloc] init] autorelease];
  
     [array addObject:obj];
  }
  </code></pre>
  
  <p><strong><em>Scenario B (explicit release):</em></strong></p>
  
  <pre><code>- (void) add {
     // array is an instance of NSMutableArray
  
     MyClass *obj = [[MyClass alloc] init];
  
     [array addObject:obj];
  
     [obj release];
  }
  </code></pre>
  
  <p>I assume both are correct, but I am not sure, and I sure don't know what the preffered way is.</p>
  
  <p>Can the Objective-C gurus shed some light on this?</p>