• 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: Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management


  • Subject: Re: Memory Management
  • From: Prachi Gauriar <email@hidden>
  • Date: Mon, 28 Jul 2003 23:16:23 -0500

On Monday, July 28, 2003, at 8:42 PM, Bill Cheeseman wrote:

on 03-07-28 2:44 PM, Marcel Weiher at email@hidden wrote:

On Monday, Jul 28, 2003, at 01:20 Europe/London, Martin Hdcker wrote:

Question: Is there a preferred method? And does one method cause
problems is used?

Yes, their is a preferred method:

This is correct.

--- snip ---
- (NSString *)name
{
return [[_name retain] autorelease];
}

This is not. Although there has been some championing of this method
by well-placed individuals, their preference has not met with an
overwhelmingly positive response, to say the least. IMNSHO, their
case, although appealing at first, has been thoroughly debunked and is
not widely supported by the Cocoa community any longer. Of course, you
may disagree with this view, but at the very least the statement that
this is the preferred method is highly controversial.

<snip>

As to whether it is "not widely supported by the Cocoa community any
longer," I would say it has _never_ been widely supported, mostly because
very few people have noticed the issue. Personally, I've been using it
myself for a long time, and it hasn't caused me any problems -- though that
is certainly faint praise. I think it is fair to say that this is the
"preferred method" at Apple, given the identity of the "well-placed
individual" of whom we speak, but I'm sure it's not currently the preferred
method outside of Apple because of the fact that very few people seem to
have noticed the issue.

Just to chime in, I think it's worth noting that the Project Builder/Xcode user scripts that generate accessor methods use the following form:

- (ClassName *)varName {
return [[[varName retain] autorelease];
}

- (void)setVarName:(ClassName *)newVarName {
if (varName != newVarName) {
[varName release];
varName = [newVarName copy];
}
}

I'd take that as a recommendation for most cases, and Ali Ozer made the same recommendation at WWDC 2002, if I remember correctly.

-Prachi
_______________________________________________
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.

References: 
 >Re: Memory Management (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Loading nib in a dynamically loaded bundle
  • Next by Date: Newbie on board
  • Previous by thread: Re: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread