I wonder what the -(void)viewDidUnload is good for. Could I not just release everything in -dealloc? If view did unload, wouldn't -dealloc be called anyways?
Enter your programming question at the top of this page and click Get An Answer.
Tell us how quickly you want your programming question answered.
Connect with your programmer via online chat or telephone call.
I wonder what the -(void)viewDidUnload is good for. Could I not just release everything in -dealloc? If view did unload, wouldn't -dealloc be called anyways?
In addition to what has already been indicated, I wanted to elaborate more about logic behind -viewdDidUnload.
One of the most important reasons for implementing it is that UIViewController subclasses commonly also contain owning references to various subviews in the view hierarchy. These properties could have been set through IBOutlets when loading from a nib, or programmatically inside -loadView, for instance.
The additional ownership of subviews by the UIViewController means that even when its view is removed from the view hierarchy and released to save memory, through which the subviews are also released by the view, they will not actually be deallocated because the UIViewController itself still contains its own outstanding retaining references to those objects as well. Releasing the UIViewController's additional ownership of these objects ensures they will be deallocated as well to free memory.
The objects that you release here are usually recreated and set again when the UIViewController's view is re-loaded, either from a Nib or through an implementation of -loadView.
Also note that the UIViewController's view property is nil by the time this method is called.
Great !!!
Byron Narciso
Programmer
Whether you have a quick question while preparing your taxes, troubleshooting a computer problem, or need to hire an attorney, ExpertHelp is the most convenient and affordable way to connect with the right service professional to get the job done.
ExpertHelp has been in business since 2011, is an A+ Rated Better Business Bureau accredited member, and offers a 100% satisfaction guarantee on every question you ask!