Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You write that it crashes when you access <code>IdataManager</code>. This is <em>not</em> true. You're program crashes when you try to access the <code>CurrentCandidate</code> object you received using the following line:</p> <pre><code>// read about naming methods here: http://cocoadevcentral.com/articles/000082.php CCandidate *currentCandidate = [IdataManager CurrentCandidate]; </code></pre> <p>I suspect you're releasing <code>currentCandidate</code> somewhere you shouldn't. It works the first time because you get back an autoreleased object (You <em>musn't</em> release those yourself!).</p> <p>This is how it goes:</p> <p>First time:</p> <ol> <li><p>Get autoreleased <code>currentCandidate</code>.<br> <strong>retain count == 2</strong></p></li> <li><p>&lt;your code&gt;</p></li> <li><p><code>[currentCandidate release]</code> or <code>[currentCandidate autorelease]</code><br> <strong>retain count == 1</strong></p></li> <li><p>&lt;your code&gt;</p></li> <li><p>All autoreleased objects get released.<br> <strong>retain count == 0</strong></p></li> <li><p><code>currentCandidate</code> gets deallocated.</p></li> </ol> <p>Second time:</p> <ol> <li>Get autoreleased <code>currentCandidate</code>. This is an invalid object that has already been deallocated. -> CRASH.</li> </ol> <hr> <p>If <code>[IdataManager CurrentCandidate</code>] <em>doesn't</em> return an autoreleased object as it should but instead just the pointer to the member of <code>IdataManager</code>, the code crashes later when accessing <code>currentCandidate</code>.</p> <p>The fact that adding <code>retain</code> helps <em>proves</em> that you're releasing <code>currentCandidate</code> somewhere. Either directly, via autorelease or though some other algorithm. All classes from Apple <em>only</em> release objects that they've retained earlier on. Somewhere in your code there's an unbalanced <code>retain</code>/<code>release</code>.</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.
    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