Properly writing an Init method
Properly writing an Init method
- Subject: Properly writing an Init method
- From: Pierre-Olivier Latour <email@hidden>
- Date: Wed, 17 Jul 2002 19:04:37 +0200
Hi,
Say I have an init method like this one:
- (id) init
{
if(self = [super init]) {
//initialize some stuff
//...
if(/* test something here*/)
return NULL; <- Memory leak?
}
return self;
}
If the initialization is not successful, I return NULL, however the memory
has already been allocated when I called [[MyClass alloc] init], so should I
add: [self dealloc] or [self release] before returning NULL in the init
method, or even [super dealloc]?
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Lausanne, Switzerland
http://www.pol-online.net
_______________________________________________
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.