Re: where does one do the autorelease?
Re: where does one do the autorelease?
- Subject: Re: where does one do the autorelease?
- From: James DiPalma <email@hidden>
- Date: Thu, 22 Jul 2004 12:10:07 -0700
COMMENT = [[NSString alloc] initWithString:@""];
[COMMENT autorelease];
Before, this code would end up leaking your old value and then
releasing your new COMMENT value.
You got it right once (autorelease your old value, retain your new
value):
[COMMENT autorelease];
COMMENT = [str copy];
But it seems by accident:
Where does one put the autorelease in the else clause, before or after
the init? I think after but before I change lots of code I'd like to be
right ;)
Please try and understand what your code is doing and why. Read some
documentation on object ownership rules.
-jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.