title: iOS: why should I deallocate first in viewDidUnload and then dealloc methods?
body: <p>I've found on Apple documentation pages an example in which they deallocate the memory as follows:</p>
  
  <pre><code>- (void)viewDidUnload
  {
    self.mapAnnotations = nil;
    [super viewDidUnload];
  
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
  }
  
  - (void)dealloc
  {
    [mapAnnotations release];
    [super dealloc];
  }
  </code></pre>
  
  <p>I was wondering why </p>
  
  <ol>
  <li><p>they first set mapAnnotation to nil in viewDidUnload and then they release in dealloc method and</p></li>
  <li><p>why they refer using to mapAnnotation with and without self.</p></li>
  </ol>
  
  <p>This is the downloadable example by the way: <a href="http://developer.apple.com/library/ios/#samplecode/MapCallouts/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009746" rel="nofollow">MapCallouts Example</a></p>