Re: Returning nil from -init
Re: Returning nil from -init
- Subject: Re: Returning nil from -init
- From: Chris Ridd <email@hidden>
- Date: Wed, 12 Mar 2003 17:35:26 +0000
On 12/3/03 4:41 pm, Mondragon, Ian <email@hidden> wrote:
>
oops - too many BOOL's on the brain...
>
>
// then you can verify the pdb argument before
>
// setting it as an ivar & not have to deal with it
>
- initWithData:(NSData *)pdb
>
{
>
if ((self = [super init]))
>
{
>
if ([self _parseData:pdb])
>
{
>
[self setData:pdb];
>
>
return self;
>
}
>
}
>
>
return nil;
>
}
>
>
sorry...
>
>
- ian
Hm, but surely that leaks 'self' if _parseData fails; the partially inited
object pointed at by self will have a retainCount of 1 and there will be no
references to it (unless the superclass has stashed a reference to it
somewhere.)
Cheers,
Chris
_______________________________________________
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.