Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The whole point of the <code>viewDidUnload</code> method is to release data that you don’t really need, in order to free memory. Read <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html" rel="noreferrer">the documentation</a>:</p> <blockquote> <p>When a low-memory condition occurs and the current view controller’s views are not needed, the system may opt to remove those views from memory. This method is called after the view controller’s view has been released and is your chance to perform any final cleanup. If your view controller stores separate references to the view or its subviews, you should use this method to release those references. You can also use this method to remove references to any objects that you created to support the view but that are no longer needed now that the view is gone. You should not use this method to release user data or any other information that cannot be easily recreated.</p> </blockquote> <p>So you’re setting the properties to <code>nil</code> in order to release the objects <em>now</em> and help the system to free up some memory. But of course this depends on the property type – strong properties are “yours” and only you can decide whether to release them now (by setting to <code>nil</code>) or not. Weak properties could already be <code>nil</code>, for example if they pointed to some views that got released with the main view. And <code>unsafe_unretained</code> properties are a special beast. The object they point to might already been released, but that does not mean they were set to <code>nil</code> automatically. So you should either use one of the “safer” property types (strong/weak), or set the unsafe properties to <code>nil</code> here, to make sure you won’t use the released object later. There are no hard rules in this case, you have to think about the situation and what it means for the various properties.</p> <p>By the way, <code>viewDidUnload</code> is getting deprecated in iOS 6, where no views are being released under low-memory conditions anymore. You still receive the <code>didReceiveMemoryWarning</code> callback, so that you can release some resources there if you want to. Again, I suggest that you read the documentation and run a few tests to see what happens and decide what you should do.</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. 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