• 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: NSMutableDictionary autorelease chrashes application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary autorelease chrashes application


  • Subject: Re: NSMutableDictionary autorelease chrashes application
  • From: Andy Lee <email@hidden>
  • Date: Fri, 18 Jul 2008 16:48:45 -0400

On Jul 18, 2008, at 4:19 PM, mmalc crawford wrote:
On Jul 18, 2008, at 11:51 AM, Andy Lee wrote:

"Autoreleased" is inaccurate and is not a proper shorthand for "you must retain it if you want it to stick around".
To understand why, consider two possible implementations of a get accessor:


- (NSString *)name {
 return name;
}
- (NSString *)name {
 return [[name retain] autorelease];
}
I don't see the difference from the caller's point of view.

NSString *name = [aPerson name];
[aPerson setName:@"Fido"];
NSLog(@"Old name: %@", name);

And calling the return value from -name "autoreleased" would imply the second implementation, which might not be the case.


Out of curiosity, is this what the docs mean in the few places they say a return value is autoreleased, or is that just someone making the same old mistake? It's trivial to find these instances by searching for "autoreleased" in Xcode.

Moreover, saying that an object is "autoreleased" also implies the overhead of adding it to an autorelease pool, suggesting that it may be more expensive to retrieve the object than is actually the case.

Okay... I thought I had a reasonable suggestion but I see it was a pretty crappy one. I'll see if I can get comfortable with the ownership terminology.


--Andy




I don't think I have ever said method X returns an autoreleased object. I was suggesting either the term could be accepted in the way that other people (and some Apple docs) use it, or someone could come up with a better term.

There is already another term -- owns. As stated initially, "autorelease" is inaccurate and misleading.

There is a reason people keep using the term incorrectly

That's exactly what you're doing here.

mmalc
_______________________________________________

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


  • Follow-Ups:
    • Re: NSMutableDictionary autorelease chrashes application
      • From: mmalc crawford <email@hidden>
References: 
 >NSMutableDictionary autorelease chrashes application (From: Matthias Arndt <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Robert Martin <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Matthias Arndt <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: "Shawn Erickson" <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: "Shawn Erickson" <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: mmalc crawford <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: Andy Lee <email@hidden>)
 >Re: NSMutableDictionary autorelease chrashes application (From: mmalc crawford <email@hidden>)

  • Prev by Date: Re: NSViewController Binding Problem continued
  • Next by Date: Re: NSMutableDictionary autorelease chrashes application
  • Previous by thread: Re: NSMutableDictionary autorelease chrashes application
  • Next by thread: Re: NSMutableDictionary autorelease chrashes application
  • Index(es):
    • Date
    • Thread