Re: MemoryWarning and loadView
Re: MemoryWarning and loadView
- Subject: Re: MemoryWarning and loadView
- From: David Duncan <email@hidden>
- Date: Mon, 24 Jan 2011 09:42:38 -0800
On Jan 24, 2011, at 8:52 AM, Bleicher Eiko wrote:
> I want to get a deeper understanding of the memory warning handling on iOS in UIViewControllers.
>
> It seems that the default implementation of didReceiveMemoryWarning will set the view to nil, and viewDidUnload gets called. *But* this is only done when the controller implements loadView. Even if this method does nothing at all except calling [super loadView].
>
> What is the reasoning behind making this behavior dependent on the existence of loadView? Also wondering how this is checked, as "respondsToSelector" might not be enough because the superclass implements it anyway?
The logic of unloading its view hierarchy depends on the ability for the view controller to reload that view hierarchy. The typical cases for this are either 1) you implement -loadView to create a view hierarchy programmatically or 2) you assign the view controller a nib to load. A plain old UIViewController should also respond to memory warnings by unloading its view, as it conforms to these conditions.
The most common case whereupon a view controller cannot unload its views is when the view controller is included in the same nib as its views (and thus archived along with those views).
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden