Re: where does one do the autorelease?
Re: where does one do the autorelease?
- Subject: Re: where does one do the autorelease?
- From: mmalcolm crawford <email@hidden>
- Date: Thu, 22 Jul 2004 11:40:57 -0700
On Jul 22, 2004, at 11:30 AM, John Spicer wrote:
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 ;)
- (void) setCOMMENT : (NSString *) str
{
if ([str isKindOfClass:[NSString class]])
{
[COMMENT autorelease];
COMMENT = [str copy];
}
else
{
COMMENT = [[NSString alloc] initWithString:@""];
[COMMENT autorelease];
}
}
Umm, why would you put it after? You're releasing the object you just
created (and leaking any previous value of COMMENT)...
<
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
Concepts/ObjectOwnership.html>
mmalc
_______________________________________________
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.