• 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: Where to release in UIView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where to release in UIView


  • Subject: Re: Where to release in UIView
  • From: Greg Guerin <email@hidden>
  • Date: Sat, 18 Jul 2009 13:28:35 -0700

DKJ wrote:

Thanks to all who replied. I was concerned whether the object might somehow get re-instantiated from the nib without dealloc being called first. If I understand memory management correctly, that would produce a leak.

I'm assuming that the object wouldn't be re-instantiated without its previous instantiation being released. But I'd sleep better having an expert opinion.

Work it through. If you understand ownership, you already have all the expertise needed.


Can awakeFromNib be called more than once on the same instance? If so, then in awakeFromNib you need to account for the possibility of shadingAreas already holding a non-nil (hence, an owned) NSDictionary instance. The reason is simple: you own that non-nil instance.

What should you do if you discover a non-nil shadingAreas in awakeFromNib? It depends on you and your design. You could use the existing instance, if that makes sense. You could release the existing instance and alloc/init a new one, if that makes sense. You could trigger an assertion that fails if this happens, it that makes sense.

None of this has any bearing on what you'd do with shadingAreas in dealloc. You have to consider ownership in each method separately.

  -- GG
_______________________________________________

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


  • Prev by Date: NSDateFormatter issue (bug maybe)?
  • Next by Date: Re: iPhone runtime browser.
  • Previous by thread: Re: Where to release in UIView
  • Next by thread: Loading GC test bundles
  • Index(es):
    • Date
    • Thread