title: UINavigationController - When to release pushed view controllers, etc
body: <p>Apologies for the big block 'o' text, but I'm somewhat of a beginner having a play around with using a UINavigationController as a part of an app I'm writing and I'm just wondering how I should handle adding view controllers to a UINavigationController and when (if ever) I should release them.</p>
  
  <p>As I see it, there are two potential approaches when adding a view controller:</p>
  
  <ol>
  <li><p>Have an instance variable for each view controller in the managing class. Initialise it (if the instance variable is nil) prior to pushing it onto the nav controller. Subsequently release the view controller in the dealloc method of the managing class if it isn't nil.</p></li>
  <li><p>Create the view controller as a local variable within a method and push it onto the navigation controller prior to immediately releasing it.</p></li>
  </ol>
  
  <p>However, I'm  unsure of the validity of each of these. (My gut feel is to go with the instance variable approach, but perhaps that's due to a lack of understanding on my part.)</p>
  
  <p>Digging a bit deeper, I suspect that my confusion is related to the fact that I don't quite grasp whether or not I'm responsible for disposing of the view controllers that are pushed onto the navigation controller stack, or whether it'll dispose of them itself when they're popped off its view controller stack. (e.g.: When the user hits the 'back' button.)</p>
  
  <p>If it's the former, then I can see that I'll need to use the instance variable approach and implement the UINavigationControllerDelegate methods in the managing object to determine when I should release and nil each view controller, etc.</p>
  
  <p>Finally (for bonus points in the afterlife) how can you easily tell if a method will increment the retain count of one of its parameters? (There don't appear to be any clues in the documentation, but perhaps I'm missing something obvious.) For example, when I use something along the lines of...</p>
  
  <pre><code>[[self navigationController] pushViewController:exampleVC animated:YES];
  </code></pre>
  
  <p>...will this increase the retain count on the view controller? (Once again, my gut feel is that it <em>should</em>, but that's about as much use as a chocolate fireguard in these dangerous times, etc.)</p>
  
  <p>Thanks in advance.</p>