Re: Accessor methods and (auto)release <Memory trail>
Re: Accessor methods and (auto)release <Memory trail>
- Subject: Re: Accessor methods and (auto)release <Memory trail>
- From: Andrew Pinski <email@hidden>
- Date: Tue, 30 Jul 2002 22:38:34 -0400
On Tuesday, July 30, 2002, at 10:34 , Ondra Cada wrote:
On Wednesday, July 31, 2002, at 04:06 , Ali Ozer wrote:
Method 2: Otherwise use the following pair, where the return
value is autoreleased in the scope of the caller, which is
more correct. This is also more (but not fully) thread-safe as
the returned value is autoreleased in the calling thread.
- (NSString *) title {
return [[title retain] autorelease];
}
Sorry, perhaps I am just plain dumb, but in what situation this
would bring any advantage to
-(NSString*)title { return title; }
? I just can't see it: we just increment the r.c. (presumably
to two, since -- being in an instance variable -- it would be
retained already), to be decremented back in some future...
regardless in what thread this is done, what is it good for?
The one case you need this is when self (of title) is dealloced
so the return of title is also dealloced.
But then again this is a rare enough case that it might not matter.
Thanks,
Andrew Pinski
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.