• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Returning nil from -init
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Returning nil from -init


  • Subject: RE: Returning nil from -init
  • From: "Mondragon, Ian" <email@hidden>
  • Date: Wed, 12 Mar 2003 12:47:22 -0600

perhaps the following would put us all at ease?

--- snip ---

- initWithData:(NSData *)pdb
{
if ((self = [super init]))
{
if ([self _parseData:pdb])
{
[self setData:pdb];
return self;
}
}

[self release];
return nil;
}

--- snip ---

> -----Original Message-----
> From: Chris Ridd [SMTP:email@hidden]
> Sent: Wednesday, March 12, 2003 11:35 AM
> To: email@hidden
> Subject: Re: Returning nil from -init
>
> 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.
_______________________________________________
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.

  • Prev by Date: Re: Returning nil from -init
  • Next by Date: Pictures
  • Previous by thread: Re: Returning nil from -init
  • Next by thread: FSSpec --> OSX Path NSString
  • Index(es):
    • Date
    • Thread