This sort of question comes up every couple of weeks. You did not use +alloc to create the string, so you do NOT need to release it. If you try to release it, the app will crash. Any of these are correct:

NSString w = [NSString stringWithFormat:@"something %i", x];
// Do stuff


NSString w = [[NSString alloc] initWithFormat:@"something %i", x];
// Do stuff
[w release];


NSString w = [NSString stringWithFormat:@"something %i", x];
[w retain];
// Do stuff
[w release];


BUT NOT:

NSString w = [NSString stringWithFormat:@"something %i", x];
// Do stuff
[w release];    // Will crash here


On 24 Oct 2008, at 06:24, Ron Green wrote:

If I call NSString w = [NSString stringWithFormat:@"something %i", x];

Am I now suppose to call retain on w?
When I'm done I know I'm suppose to release w.
_______________________________________________

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/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to