1
votes

for a UIViewController which methods should a "release" and set to "nil" the outlets/instance 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
2

2 Answers

1
votes

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];
0
votes

I believe that in -dealloc, you should use the ivars directly; in other cases as like -viewDidUnload, you’ll want to nil the properties.