• 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: 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.

  • Prev by Date: Re: I want ALL my tiff pixels
  • Next by Date: Re: Getting the amount of free space on a volume
  • Previous by thread: RE: Returning nil from -init
  • Next by thread: RE: Returning nil from -init
  • Index(es):
    • Date
    • Thread