I have seen some Apple examples that do call [super viewDidUnload];
and some that don't. I read an article (a few months ago so I dont recall the url) that said calling [super viewDidUnload];
was unnecessary but it didn't explain beyond that.
Is there a definitive reason why or why not to tell super that the viewDidUnload
?
And, (if it should be done) do I call super before setting all my properties to nil
, after, or does it matter?
- (void)viewDidUnload {
// Is this necessary?
// [super viewDidUnload];
self.tableDataSource = nil;
self.titleLabel = nil;
// Is it better to call super before or after nil'ing properties?
// [super viewDidUnload];
}
Thanks!
1- Is there a definitive reason why or why not to tell super that the viewDidUnload?
Honestly I don't know the consequences of not calling it. You can try to not call it and everything works smooth, but imagine that Apple adds some importante piece of code that will run when
[super viewDidUnload]
is called, what will happen now? Bad things will happen probably and you will spend precious time trying to solve your problem. My rule is: when overriding, call the super.2 - Do I call super before setting all my properties to nil, after, or does it matter?
It does matter, I have watched bad things happen when I called [
super dealloc]
before releasing my objects. The same way I saw my UI being slow because I did my calculations before[super viewDidLoad]
. It always depend of what you want to achieve.Bottom line, what I do in my projects for
viewDidUnload
is:As for iOS6:
The method has been deprecated.