for a UIViewController which methods should a "release" and set to "nil" the outlets/ins开发者_开发问答tance variables?
That which of the methods out of "viewDidUnload" and "dealloc" should I be putting:
- The "release" for outlets or other member variables in the class, and
- The "xxx = nil" (i.e. set to nil) in
In viewDidUnload typical practice is to nil, using accessors, any objects embedded in the view controller's view - buttons, views, textfields, any descendant of UIView that could be in the view hierarchy:
self.myButton = nil;
In dealloc you should release ALL retained variables directly, including subviews:
[myButton release];
[someStateObject release];
I believe that in -dealloc
, you should use the ivars directly; in other cases as like -viewDidUnload
, you’ll want to nil the properties.
精彩评论