开发者

for a UIViewController which methods should a "release" and set to "nil" the outlets/instance variables?

开发者 https://www.devze.com 2023-03-07 13:12 出处:网络
for a UIViewController which methods should a \"release\" and set to \"nil\" the outlets/ins开发者_开发问答tance variables?

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:

  1. The "release" for outlets or other member variables in the class, and
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消