Reputation: 773
I would like to know if there is any difference between calling [super viewDidUnload] before realeasing properties or after it.
Thank you!
self.webView = nil;
self.fullText = nil;
[super viewDidUnload];
or
[super viewDidUnload];
self.webView = nil;
self.fullText = nil;
Upvotes: 23
Views: 4923
Reputation: 6510
This is just like the dealloc method.
- (void)dealloc
{
[array release];
[super dealloc];
}
So I think we should call [super viewDidUnload]
last.
Upvotes: 2
Reputation: 4718
I never thought it mattered, but we just found a bug where the app crashed calling it first. The trend at my office has been to call it last, but the Apple template puts it first.
You can do what you want, but I will always call it last from now on.
Upvotes: 10
Reputation: 512
This question is not fully answered. (And it's first hit when I google on this topic, so a complete answer would be useful to me and others.)
If the superclass DOES something in viewDidUnload, then what is the correct order for calling it in your class's viewDidUnload: before or after releasing properties?
For the record, it seems the consensus is to call the super method LAST:
-(void)viewDidUnload {
self.some_property = nil;
[super viewDidUnload];
}
Upvotes: 6
Reputation: 4339
This only matters if the superclass of your view actually does something in viewDidLoad
. The default UIViewController
doesn't do anything in viewDidLoad
so if your view is a standard UIViewController
then you can put [super viewDidLoad]
anywhere in the viewDidLoad
method. However, if super
does something in viewDidLoad
, then it does matter where you put [super viewDidLoad]
.
Upvotes: 2
Reputation: 32316
This depends on what the superclass does in viewDidUnload
. If it's just a standard UIViewController
, either will do because -[UIViewController viewDidUnload]
does nothing.
Upvotes: 12