• 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: Accessor methods and (auto)release <Memory trail>
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessor methods and (auto)release <Memory trail>


  • Subject: Re: Accessor methods and (auto)release <Memory trail>
  • From: Ondra Cada <email@hidden>
  • Date: Wed, 31 Jul 2002 04:34:42 +0200

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?

What might be reasonable IMHO is

-(NSString*)title {
return [[title copy] autorelease];
}

especially in cases title happens to be mutable... Though, in the retain/autorelease pair I see no sense... so I am probably blind, but what have I overlooked?
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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.
  • Follow-Ups:
    • Re: Accessor methods and (auto)release <Memory trail>
      • From: Ali Ozer <email@hidden>
    • Re: Accessor methods and (auto)release <Memory trail>
      • From: Andrew Pinski <email@hidden>
References: 
 >Re: Accessor methods and (auto)release <Memory trail> (From: Ali Ozer <email@hidden>)

  • Prev by Date: Re: Accessor methods and (auto)release <Memory trail>
  • Next by Date: Re: Accessor methods and (auto)release <Memory trail>
  • Previous by thread: Re: Accessor methods and (auto)release <Memory trail>
  • Next by thread: Re: Accessor methods and (auto)release <Memory trail>
  • Index(es):
    • Date
    • Thread