• 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: Should objects returned by indirection be autoreleased
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should objects returned by indirection be autoreleased


  • Subject: Re: Should objects returned by indirection be autoreleased
  • From: Eric <email@hidden>
  • Date: Sat, 13 May 2006 12:57:49 -0700

I think there's really two questions here, one is whether NSCell will retain
representedObject for itself (throughout its lifetime), and the other is
whether NSCell weill retain representedObject for me.  The answer is yes for
the former, and no for the latter.

I believe my original question is about the former rather than the latter.
And Bill correctly points out that I can assume NSCell would retain
representedObject throughout its lifetime for its own use -- in the same
fashion that NSArray retains its objects -- in order to be able to return it
later.  Furthermore, since my subclass of NSCell doesn't modify the
retain/release behavior of representedObject of its superclass (NSCell), it
can also assume representedObject will be retained and released
appropriately for itself, to ensure it's allocated while it's alive and
deallocated when it dies.  (Since after all, my NSCell subclass is looking
at things from NSCell's perspective, since it is also a NSCell)

I don't think I have any confusion regarding the latter question.  Namely,
if I get an object from NSCell (other than it's alloc, copy...etc. methods),
I know NSCell is not going to retain it for me but only for itself, so I'm
going to retain it if I'm going to use it beyond this event loop (or
scope).   Otherwise, NSCell would release it under my feet when it dies
while I'm still using it.

-------------------------------------------------------------

Now comes another question that Bill brought up, of whether it's appropriate
to use representedObject for my purpose.  What I have is a NSCell that
represents a bookmark button.  I'm using the representedObject to refer to
the actual bookmark model object it represent.  Does this warrant the use of
representedObject?

Thanks again,
Eric
_______________________________________________
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: Should objects returned by indirection be autoreleased
      • From: Bill Bumgarner <email@hidden>
    • Re: Should objects returned by indirection be autoreleased
      • From: Eric <email@hidden>
References: 
 >Should objects returned by indirection be autoreleased (From: Eric <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Jim Correia <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Jim Correia <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Eric <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Lon Giese <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Bill Bumgarner <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Lon Giese <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Bill Bumgarner <email@hidden>)
 >Re: Should objects returned by indirection be autoreleased (From: Lon Giese <email@hidden>)

  • Prev by Date: Re: compressing an NSString
  • Next by Date: Re: Should objects returned by indirection be autoreleased
  • Previous by thread: [Moderator] EOT Re: Should objects returned by indirection be autoreleased
  • Next by thread: Re: Should objects returned by indirection be autoreleased
  • Index(es):
    • Date
    • Thread