• 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: of nibs and top level objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: of nibs and top level objects


  • Subject: Re: of nibs and top level objects
  • From: Martin Wierschin <email@hidden>
  • Date: Mon, 10 Apr 2006 02:16:50 -0700

Ughh this retain stuff can still be confusing. The meaning of his comment finally struck me stupid:
// nibInstantiateWithOwner retains each top level object
[topLevelObjects makeObjectsPerformSelector:@selector (release)];


Which means that we wasn't intending the objects to be left owned by the array, but to be not doubly retained by being in the array.

I think this point might benefit from some discussion, if just for the sake of the archives. From my view, it looks like this bit of code is exactly written so that the top level objects (TLOs) are left owned by the array, and the array alone.


Adding the objects to the array does not do a double retain. As joar said, the TLOs have a retain count of 1 just by virtue of being created by the Nib machinery. Once you place these TLOs into the array they each have a retain count of 2. To properly deconstruct the TLOs you need to not only release the array, but also send all TLOs an individual -release message. The code quoted above sends all of the TLOs a release immediately after being placed into the array, so clients of the convenience method no longer have to worry about this.

Personally I think this is a little more complicated than it needs to be. If you provide the Nib loading machinery with a TLO array, why place the burden on the caller to release all these objects manually before releasing the array? Furthermore, I feel like the Nib machinery should require a TLO array, otherwise the caller is certain to be leaking objects.

Cheers,
~Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: of nibs and top level objects
      • From: Paul Forgey <email@hidden>
References: 
 >of nibs and top level objects (From: Paul Forgey <email@hidden>)
 >Re: of nibs and top level objects (From: j o a r <email@hidden>)
 >Re: of nibs and top level objects (From: Paul Forgey <email@hidden>)
 >Re: of nibs and top level objects (From: Paul Forgey <email@hidden>)

  • Prev by Date: Re: of nibs and top level objects
  • Next by Date: Reg NSNibControlConnector & NSNibOutletConnector
  • Previous by thread: Re: of nibs and top level objects
  • Next by thread: Re: of nibs and top level objects
  • Index(es):
    • Date
    • Thread