• 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: Nib ownership and retain count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nib ownership and retain count


  • Subject: Re: Nib ownership and retain count
  • From: Ken Thomases <email@hidden>
  • Date: Fri, 25 Jan 2008 10:56:25 -0600

On Jan 24, 2008, at 4:01 PM, Keary Suska wrote:

I overrode my object's release method and released the top level objects when
my retain count hit one, hoping that whatever Nib object was retaining my
object would release it, but that didn't work.

A simple search of the archives, and reviewing some very recent threads,
never, ever, ever rely on retain count for *anything*. Ultimately, it's none
of your code's business. That being said, your release method would simply:
1) [topLevelObjects release] and 2) [super release] . That should be enough
to release everything as soon as the current autorelease pool is drained,
and as long as you aren't needlessly retaining.

This is very wrong. Your release method may be called many times over the object's lifetime, but should only release topLevelObjects once -- on the last release. Or preferably, on dealloc, if you can resolve the retain cycle that's preventing the object from being fully released.


If the nib is primarily for a window, then NSWindowController is a good way to go. It takes care of loading the nib, managing the top- level objects, and breaking certain retain cycles which crop up if the nib objects have bindings to or through the File's Owner.

-Ken
_______________________________________________

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: Nib ownership and retain count
      • From: Keary Suska <email@hidden>
References: 
 >Re: Nib ownership and retain count (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: bytesize of an object
  • Next by Date: Re: bytesize of an object
  • Previous by thread: Re: Nib ownership and retain count
  • Next by thread: Re: Nib ownership and retain count
  • Index(es):
    • Date
    • Thread