I'd like to know whether or not both viewDidUnload
and dealloc
are always called in succession in the UIViewController tear-down process. Is it possible that dealloc
could be called on my view controller without viewDidUnload
having been called first?
In either case, if I am safely releasing the properties and retained references in both methods it wouldn't be a problem if both methods were called -- but I was wondering if anyone knew for sure or could shed some light on the tear-down process.
2012 Update: It's handy to note that as if iOS 6 viewDidUnload
has been deprecated and should be replaced with manual view teardown if required in didReceiveMemoryWarning
.
A good article on the new UIView/UIViewContoller and the new behaviour and it's effects on the joe conway blog
viewDidUnload
will not be called every time like dealloc
method. viewDidUnload
is called only when your app receives low memory warning!
Just think, if you are releasing your object both in viewDidUnload
and dealloc
methods. If both gets called every time, then you are releasing already released object, which will lead to application crash, isn't it?. viewDidUnload
is a place provided by the Apple for cleaning up the things when receiving the low memory warning because you know in iPhone we have memory restriction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With