Re: Init Question
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.