title: What's the magic of NSAutoreleasePool in Objective-C/cocoa framework?
body: <p>I found an example of Objective-C/cocoa framework has the following code.</p>
  
  <pre><code>int main()
  {
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  
      // Create an array
      NSArray *month = [NSArray arrayWithObjects:@ ... nill];
  
      [pool drain];
  }
  </code></pre>
  
  <ul>
  <li><p>Q1 : What's the magic behind this (Why do I need to have the NSAutoreleasePool code?)? What magic is happening between the <code>NSAutoreleasePool</code> and <code>pool drain</code> block? I see I don't need to release<code>*month</code> myself. Is this because it's inside the <code>NSAutoreleasePool</code> and <code>pool drain</code> block?</p></li>
  <li><p>Q2 : With Xcode, I'm already given the main() function. In this case, how can I use the <code>NSAutoreleasePool</code> and <code>pool drain</code>?</p></li>
  </ul>
  
  <p>For example :</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      //NSAutoreleasePool *pool = [[[NSAutoreleasePool] alloc] init];
      return NSApplicationMain(argc,  (const char **) argv);
  }
  </code></pre>