Re: Question about scope of "convenience objects"
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