Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>This answer from the previous decade,</h1> <h1>is now only of historic interest.</h1> <p><strong>Today, you must use ARC.</strong></p> <p>Cheers</p> <hr> <p>The very short answer is <strong><em>DO NOT</em></strong> just set it to nil. <strong><em>You must release it.</em></strong> Setting it to nil has no connection to releasing it. You must release it.</p> <p>However it's worth remembering that <strong>if it is a property</strong>, then</p> <pre><code>self.obj = nil; </code></pre> <p>will in a fact release it for you. Of course, you must not forget the "self." part !!!!</p> <p>Indeed,</p> <pre><code>self.obj = anyNewValue; </code></pre> <p>will indeed release the old memory for you, clean everything up magically and set it up with the new value. So, self.obj = nil is just a special case of that, it releases and cleanses everything and then just leaves it at nil.</p> <p>So if anyone reading this is new and completely confused by memory,</p> <ol> <li><p>You must release it, [x release] before setting it to nil x=nil</p></li> <li><p><strong>IF</strong> you are using a property, "don't forget the self. thingy"</p></li> <li><p><strong>IF</strong> you are using a property, you can just say self.x=nil or indeed self.x=somethingNew and it will take care of releasing and all that other complicated annoying stuff.</p></li> <li><p>Eventually you will have to learn all the complicated stuff about release, autorelease, blah blah blah. But life is short, forget about it for now :-/</p></li> </ol> <p>Hope it helps someone.</p> <h1>Again note, this post is now totally wrong. Use ARC.</h1> <h1>Historic interest only.</h1>
    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. 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