• 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: Init Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Init Question


  • Subject: Re: Init Question
  • From: "Ian P. Cardenas" <email@hidden>
  • Date: Sat, 25 Oct 2003 19:17:25 -0500

On Oct 25, 2003, at 18:47, Jon Hull wrote:
So if my initializer receives bad data, should it call [self dealloc] and return nil?

no, you should release self, assign nil to self and then return self.

something like the following:

-(id)initWithObject:(id)initParam
{
self = [super init];
if (self != nil)
{
if ([initParam isValid]) //for example
{
//proceed with initialization
}
else
{
//do whatever cleanup you need to then:
[self release];
self = nil;
}
}
return self;
}

as a general rule, you should never call -dealloc directly.

--
Ian P. Cardenas
Computer Scientist, Software
_______________________________________________
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.

References: 
 >Init Question (From: Jon Hull <email@hidden>)
 >Re: Init Question (From: Ambroise Confetti <email@hidden>)
 >Re: Init Question (From: Jon Hull <email@hidden>)

  • Prev by Date: Inspector of NSArrayController doesn't update NSTable immediately
  • Next by Date: NSColor colorWithPatternImage: texture origin?
  • Previous by thread: Re: Init Question
  • Next by thread: Object Compatibility Method?
  • Index(es):
    • Date
    • Thread