• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How are views supposed to reload after being nillified by memory warnings?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How are views supposed to reload after being nillified by memory warnings?


  • Subject: Re: How are views supposed to reload after being nillified by memory warnings?
  • From: David Duncan <email@hidden>
  • Date: Mon, 05 Mar 2012 10:03:24 -0800

On Mar 3, 2012, at 8:57 AM, Matt Neuburg wrote:

> On Fri, 02 Mar 2012 10:17:43 -0800, David Duncan <email@hidden> said:
>> On Mar 2, 2012, at 1:28 AM, G S wrote:
>>
>> In the vast majority of cases where I've seen this behavior, it is because in your delegate handler for the UIImagePickerController, you assign the returned image directly to a UIImageView that you have in your view hierarchy. If you've recently gotten a memory warning, then this image view is either nil, or will be released very soon, and you will end up with a view that has no image.
>
> So let's say I have a view controller. And let's say that its view (self.view) contains a UIImageView in its hierarchy (self.view.imageview). You are saying that the runtime might summarily rip the UIImageView out of the interface, so that self.view is *not* nil but self.view.imageview *is* nil???


No. But if you've presented a modal view controller, your entire view hierarchy (self.view) has been ripped out of the window, and if a memory warning arrives, then self.view will be set to nil. What happens next depends on if you implemented -viewDidUnload properly or if your view references are strong or weak.

If they are strong and you did not implement -viewDidUnload properly, then your view reference will be non-nil. On the next load however, that reference will be replaced by a newly created view. If they are weak, or you implemented -viewDidUnload properly, then the view reference will be nil, and the usual message to nil semantics will take over.
--
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


  • Follow-Ups:
    • Re: How are views supposed to reload after being nillified by memory warnings?
      • From: G S <email@hidden>
    • NSURLRequests and Firewalls
      • From: Alex Zavatone <email@hidden>
References: 
 >Re: How are views supposed to reload after being nillified by memory warnings? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Releasing WSMethodInvocationInvoke()
  • Next by Date: NSURLRequests and Firewalls
  • Previous by thread: Re: How are views supposed to reload after being nillified by memory warnings?
  • Next by thread: NSURLRequests and Firewalls
  • Index(es):
    • Date
    • Thread