Re: Checkboxes and NSBox titles
Re: Checkboxes and NSBox titles
- Subject: Re: Checkboxes and NSBox titles
- From: John Hörnkvist <email@hidden>
- Date: Wed, 13 Jun 2001 11:57:13 +0200
On Wednesday, June 13, 2001, at 04:09 AM, Fritz Anderson wrote:
Begging pardon, but I thought one did
- (void) setMyVal: (id) newVal
{
[myVal autorelease];
myVal = [newVal retain];
}
... yes? Because those methods are no-ops when sent to nil, and
-retain always returns self? No need for conditionals, and no fear of
deallocating myVal if myVal==newVal?
I prefer this form:
- (void) setMyVal: (id) newVal
{
[newVal retain];
[myVal release];
myVal =newVal;
}
It avoids autorelease, and as I see it is much better description of
what you want to do.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com