Re: NSMutableDictionary autorelease chrashes application
Re: NSMutableDictionary autorelease chrashes application
- Subject: Re: NSMutableDictionary autorelease chrashes application
- From: mmalc crawford <email@hidden>
- Date: Fri, 18 Jul 2008 13:19:50 -0700
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);
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.
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