On Wed, May 27, 2009 at 11:05 AM, Erik Buck <erik.b...@sbcglobal.net> wrote:
> As an alternative, use
> NSString *string1 = [[NSString stringWithString:@"myFirstString"] retain];
> or NSString *string2 = [[NSString alloc] initWithString:@"mySecondString"];
> or NSString *string3 = [@"myThirdString" copy];

However you should never use any of these either.

You already have a string. If you need a string, then you have it, so use it.

This code can be *occasionally* useful if you need an independent copy
of a potentially mutable string. But of course @"" constructs are
never mutable.

This may seem nitpicky but I see a lot of newbies writing code just
like this. Their code is filled with stringWithString: calls for
absolutely no purpose, so I want to discourage that sort of thing.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to