[英]for a UIViewController which methods should a “release” and set to “nil” the outlets/instance variables?
for a UIViewController which methods should a "release" and set to "nil" the outlets/instance variables? 对于UIViewController,应将哪个方法“释放”并设置为“ nil”的插座/实例变量?
That which of the methods out of "viewDidUnload" and "dealloc" should I be putting: 我应该在“ viewDidUnload”和“ dealloc”中使用哪种方法:
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: 在viewDidUnload中,典型的做法是使用访问器将嵌入在视图控制器视图中的任何对象(按钮,视图,文本字段,可能位于视图层次结构中的UIView的任何后代)设为零:
self.myButton = nil;
In dealloc you should release ALL retained variables directly, including subviews: 在dealloc中,您应直接释放所有保留的变量,包括子视图:
[myButton release];
[someStateObject release];
I believe that in -dealloc
, you should use the ivars directly; 我相信在
-dealloc
,您应该直接使用ivars。 in other cases as like -viewDidUnload
, you'll want to nil the properties. 在其他情况下(如
-viewDidUnload
,您将想要使属性为零。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.