Re: Autorelease Question
Re: Autorelease Question
- Subject: Re: Autorelease Question
- From: Filip van der Meeren <email@hidden>
- Date: Fri, 21 Nov 2008 08:14:23 +0100
They are.
On 21 Nov 2008, at 02:54, Klaus Backert wrote:
Am 20.11.2008 um 22:04 schrieb Adam Leonard:
Just to clarify:
They probably are identical, but not in the way everyone seems to
be assuming.
To make sure I don't misrepresent anything, I'll just quote the rule:
"You take ownership of an object if you create it using a method
whose name begins with "alloc" or "new" or contains "copy" (for
example, alloc, newObject, or mutableCopy), or if you send it a
retain message."
Nothing in that rule says or implies that objects you get through
other methods are autoreleased.
See the Cocoa Fundamentals Guide:
"Class factory methods are implemented by a class as a convenience
for clients. They combine allocation and initialization in one step
and return the created object autoreleased. These methods are of the
form + (type)className... (where className excludes any prefix)."
"autoreleased" !
Because of this the following statements are identical, as far as I
can see:
NSString *blah = [[[NSString alloc] init] autorelease];
NSString *blah = [NSString string];
Aren't they?
Klaus
_______________________________________________
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
Filip van der Meeren
http://www.sourceforge.net/projects/xlinterpreter
_______________________________________________
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