Note that there are some explanatory texts on larger screens.

plurals
  1. POrelease view in viewDidUnload
    primarykey
    data
    text
    <p>I know that if I retain an IBOutlet by using property then I have to set it to nil in <code>viewDidUnload</code> but what about others?</p> <p>For example, i have three subviews view1, view2 and view3, that load from nib and that is the controller's header file</p> <pre><code>@interface MyViewController : UIViewController { IBOutlet UIView *view1; UIView *view2; //no reference for view3 } @property (nonatomic, retain) IBOutlet UIView *view2; //property view2 is an IBOutlet!! @end </code></pre> <p>and method <code>viewDidUnload</code></p> <pre><code>- (void)viewDidUnload { self.view2 = nil; //[view1 release]; //view1 = nil; [super viewDidUnload]; } </code></pre> <p>do I have to release view1 and set it to nil? or UIViewController will set it to nil for me? what about view3?</p> <p>also do I have to release view1 in <code>dealloc</code>?</p> <p>edit: I think many people does not understand my question</p> <p>Firstly, view1 is an IBOutlet which declared as an ivar and assign an ivar will not retain it. I know that UIViewController definitely will retain it but do i have to release it or UIViewController will release it for me? If UIViewController will release it then there is no point that i have to release it again.</p> <p>Secondly, view2 is also an IBOutlet although it is declared as a property not ivar.</p> <pre><code>@property (nonatomic, retain) IBOutlet UIView *view2; </code></pre> <p>It is a retain property, therefore set it will retain it so I know that I have to set it to nil in order to release it. I have no problem about it.</p> <p>For view3, there is no reference for it, therefore I am assuming I don't have to do anything about it. I also assuming there is no need to make a reference for <code>every</code> object in nib.</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.
 

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