On Mar 9, 2010, at 1:41 PM, Laurent Daudelin wrote:

> I've been running in that situation and I'm just wondering if there are any 
> advice for/against one or the other method.
> 
> For example, is:
> 
> NSMutableArray *anArray = [[NSMutableArray array] retain];

There is no reason to use this when you mean

> 
> NSMutableArray *anArray = [[NSMutableArray alloc] init];

Both examples yield an NSMutableArray object with a retain count of 1. The 
first example invokes an autorelease which is canceled out by a retain. The 
first example could be rewritten as [[[[NSMutableArray alloc] init] 
autorelease] retain]; When you compare that to the second example, it's easy to 
see why there's no reason to use the first.

Luke_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to