Re: Best practice for overridden initializers in subclasses
Re: Best practice for overridden initializers in subclasses
- Subject: Re: Best practice for overridden initializers in subclasses
- From: Andy Lee <email@hidden>
- Date: Tue, 25 Mar 2008 23:47:47 -0400
On Mar 25, 2008, at 8:09 PM, Quincey Morris wrote:
On Mar 25, 2008, at 16:26, Andy Lee wrote:
- (id)init
{
NSLog(@"%@ -- '%@' is not the designated initializer",
[self class],
NSStringFromSelector(_cmd));
[self release];
return nil;
}
Unless there is some special runtime magic going on, this seems not
absolutely safe. Your '[self release]' is going to eventually lead
to a call of '[super dealloc]' and theoretically you can't safely
call the superclass's dealloc if you haven't called a designated
superclass initializer, because you don't know what the superclass's
dealloc expects its initializer to have already done.
Ah, I hadn't thought of that -- I should have looked more closely at
your code.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden