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 01:39:22 +0200
On Tuesday, June 12, 2001, at 11:42 PM, John C. Randolph wrote:
- (void) setTitleCell:(NSCell *) aCell
{
if (aCell && (_titleCell != aCell))
[_titleCell release];
[_aCell retain];
_titleCell = aCell;
}
aCell==_tileCell; would cause a memory leak, wouldn't it?
I'd just reverse the order of the retain and release;
- (void) setTitleCell:(NSCell *) aCell
{
[aCell retain]; // Retain aCell first; its good practice
[_titleCell release];
_titleCell = aCell;
}
(Well, maybe one should protect against aCell==nil, in case there are
unguarded [_titleCell size] calls and such in there. Otherwise I think
one should be able to set the cell to nil...)
- (void) setTitleCell:(NSCell *) aCell
{
if (aCell && (_titleCell != aCell))
{
[aCell retain]; // Retain aCell first; its good practice
[_titleCell release];
_titleCell = aCell;
}
}
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com