Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>it's worth you getting to grips with iPhone memory management a little more.</p> <p>Basically, an [alloc] and a [copy] both increase your retain count by one. So the following line:</p> <pre><code>cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; </code></pre> <p>increments the retain count on your new cell object, from zero to one.</p> <p>You <em>could</em> then manually decrease the retain count back to zero when you were done with it, by typing the following:</p> <pre><code>[cell release]; </code></pre> <p><strong>instead</strong> of the autorelease. This would reduce its retain count to zero, at which point the iPhone system will automatically dealloc the memory for this object. [Note that you never call [cell dealloc] directly - rather, dealloc automatically happens when the retain count goes back to zero.]</p> <p><strong>However</strong>, you don't easily know when that cell will no longer be required. So instead you use [autorelease].</p> <p>Without going into the depths of how autorelease works, effectively it gathers all objects that are no longer referenced and releases them (and therefore deallocs them) at the start of the next run cycle.</p> <p>As long as you have a reference to the cell object it will not be autoreleased. The moment you have no reference to it, it will be added to the autorelease pool and will be dealloc'd in due course.</p> <p>Sorry it's a bit involved - does that help??!</p>
    singulars
    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. 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