title: ARC releases my object somewhere in Apple's UI library
body: <p>I have a local variable <code>UINavigationConroller *nav</code>. Not 10 lines after it's declared, within the same method, it is passed to <code>[self presentViewController:nav animated:YES completion:nil]</code> (<code>self</code> is a <code>UIViewController</code>). I know passing <code>nil</code> here is OK because <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instm/UIViewController/presentViewController:animated:completion:" rel="nofollow noreferrer">the documentation says it is</a>.</p>
  
  <p>Just before passing it in, everything's fine. However, while it's in there ARC deallocates it and the app soon crashes when something in Apple's UI library calls <code>[UINavigationController isKindOfClass:]</code>, presumably on my <code>nav</code> object. Here's the console output:</p>
  
  <pre><code>2015-03-20 13:33:50.729 Now[9183:3980870] Presenting view controllers on detached view controllers is discouraged &lt;MyViewController: 0x125042200&gt;.
  2015-03-20 13:33:50.730 Now[9183:3980870] *** -[UINavigationController isKindOfClass:]: message sent to deallocated instance 0x12601c6e0
  </code></pre>
  
  <p>I've been stepping in, out, and through this class and assembly code for a couple days, Googling as much as I can, and can't seem to fix it. My only solution left was to call <code>[nav retain]</code> just before <code>presentViewController</code>, and <code>[nav release]</code> immediately after, but ARC forbids this. This is a huge, old project so <strong>we can't just turn off ARC.</strong></p>
  
  <p><strong>How do I keep <code>nav</code> form being deallocated before it's done being used?</strong></p>
  
  <h2>Update:</h2>
  
  <hr>
  
  <p>I've inspected this using the Zombie profiler. I've discovered that it is indeed a <code>UINavigationController</code>, and is indeed being deallocated within UIKit:</p>
  
  <p><img src="https://i.stack.imgur.com/RdymG.jpg" alt="A screenshot of the Zombie profiler"></p>
  
  <p>The most telling thing is the top two lines, which show it going from 960B on allocation, immediately to 0:</p>
  
  <p><img src="https://i.stack.imgur.com/6tlzA.png" alt="A screenshot of the top 2 frames in the Zombie proviler, hilighting the immediate nullification"></p>
  
  <p>I'm this looks atypical, and throws up red flags for me.</p>