Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Welcome to iOS programming. Your crash is a memory management issue. It may take you a bit to get the hang of it but memory management gets way easier if you just follow one rule:</p> <p><strong>an object needs to release anything it retains (alloc is equivalent to retain)</strong></p> <p>In this case, your view controller is releasing itself and it definitely did not retain itself. Here's how the sequence works with a navigation controller:</p> <ol> <li><p>The navigation controller is initialized with a root view controller (the first one on its stack). Lets call this <code>firstViewController</code></p></li> <li><p>A user action tells <code>firstViewController</code> to initialize <code>secondViewController</code> and push it onto the navigation controller. In most cases, <code>firstViewController</code> will release the instance of <code>secondViewController</code> after pushing it. At this point, <code>firstVC</code> is done with <code>secondVC</code>. The navigation controller is now retaining <code>secondVC</code></p></li> <li><p>User touches the back button on the navigation bar of <code>secondVC</code>. The navigation controller will pop <code>secondVC</code> from the stack and release it. As long as no other object is retaining it, <code>secondVC</code> will get be dealloc'ed.</p></li> <li><p>Now user is back in <code>firstVC</code>. They can do the same user action which will init and push a new instance of <code>secondVC</code>.</p></li> </ol> <p>Hope that helps a bit.</p> <p>I'd also recommend you (re)read the Apple docs and look at the sample code referenced in the framework docs.</p> <p><a href="http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html" rel="nofollow">http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload