• 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: Question about scope of "convenience objects"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about scope of "convenience objects"


  • Subject: Re: Question about scope of "convenience objects"
  • From: "Shawn Erickson" <email@hidden>
  • Date: Fri, 21 Sep 2007 12:27:15 -0700

On 9/21/07, Scott Ribe <email@hidden> wrote:
> >   I see some prefer the style (on a "getter" accessor method) of:
> >
> >   return [[object retain] autorelease];
>
> In an accessor method, that makes sense for objects that might be shared
> between threads.

It makes the most sense for framework developers that want to help
protect callers from side effects. For example an unrelated (from the
prespective of the caller) setter could result in the object returned
by the getter to be deallocated while still in the current stack frame
(function/method). So using [[object retain] autorelease] will ensure
that the vended object continues to exist in the callers autorelease
pool and wont disappear when the caller uses some other aspect of the
API.

-Shawn
_______________________________________________

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

References: 
 >Re: Question about scope of "convenience objects" (From: "I. Savant" <email@hidden>)
 >Re: Question about scope of "convenience objects" (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: really weird move file problem - copy fails also, more datapoints
  • Next by Date: Re: really weird move file problem
  • Previous by thread: Re: Question about scope of "convenience objects"
  • Next by thread: Image Batch Processing
  • Index(es):
    • Date
    • Thread