title: iPhone NSMutableArray release problem
body: <p>I have two controllers, SyncController and XMLController. SyncController sends some parameters to XMLController, which connects to an API and wraps the result as objects within an NSMutableArray, and returns the array back to the SyncController.</p>
  
  <p>Some code:</p>
  
  <p>SyncController.h</p>
  
  <pre><code>-(void)urlHandler:(NSArray *)urlHandler listObjectsFinishedLoading:(NSMutableArray *)resultData;
  </code></pre>
  
  <p>SyncController.m</p>
  
  <pre><code>- (void)urlHandler:(NSArray *)urlHandler listObjectsFinishedLoading:(NSMutableArray *)resultData;
  {
    NSMutableArray *receivedObjects = [[NSMutableArray alloc] init];
    [receivedObjects addObjectsFromArray:resultData];
    for (Object *o in receivedObjects) {
       //DO SOME STUFF
    }
    [receivedObjects release];
  }
  </code></pre>
  
  <p>XMLController.h</p>
  
  <pre><code>@interface XMLController : NSObject {
      NSMutableArray *objects;
  }
  @property (nonatomic, retain) NSMutableArray *objects;
  </code></pre>
  
  <p>XMLController.m</p>
  
  <pre><code>-(void) connectionDidFinishLoading:(NSURLConnection *) connection {
    objects = [[NSMutableArray alloc] init];
  
    if ([delegate respondsToSelector:@selector(urlHandler:listObjectsFinishedLoading:)]) {
      [delegate urlHandler:self listObjectsFinishedLoading:objects];
    }
  
    //[objects release];
  }
  
  -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI
  qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
  {
    // Initialize an Object
  }
  -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI
  qualifiedName:(NSString *)qName
  {
    // Put some properties unto Object
    // Ad Object to the objects array
    // release Object
  }
  
  - (void)parserDidEndDocument:(NSXMLParser *)parser
  {
     //[objects release];
  }
  
  - (void)dealloc {    
      //[objects release];
      [super dealloc];
  }
  </code></pre>
  
  <p>My question is, how do I properly release the objects array? If I don't release it, the code works properly (the actions from //DO SOME STUFF are executed) but it obviously leaks. If I release it, wherever I do it (see the commented //[objects release]; in three places) the app crashes.  </p>
  
  <p>Any suggestions? Thanks.</p>