You should do.
viewDidUnload
is called in low memory condition. So if you want to clean up call self.yourOutlet = nil
also in this method. Furthermore it allows you to save extra memory for your app.
The next time (after viewDidUnload
method is called) your view
will be loaded into memory again (viewDidLoad
will be called) and your outlet will be set up correctly.
As a rule of thumb any IBOutlet
s you release in dealloc
, should also be released (reference set to nil like self.label = nil
) in this method.
A note
You should not call self.label = nil;
in dealloc
. Instead do [label_ release];
as documented in Apple Memory Management Guide.
In addition, Stack Overflow search is your friend:
When is UIViewController viewDidUnload called?
When should I release objects in -(void)viewDidUnload rather than in -dealloc?
Hope that helps.
Edit
if you not use ARC (I think not) you should call also [super dealloc];
like the following:
- (void)dealloc
{
[label_ release];
[super dealloc];
}