Best practice for overridden initializers in subclasses

2008-03-25 Thread Andy Klepack
I have a subclass of NSObject that provides its own designated initializer that allows client code to configure an instance with initial values. Instances of the class itself are immutable. At the same time, instances where no initial values are supplied do not make conceptual sense. I'm

Re: Best practice for overridden initializers in subclasses

2008-03-25 Thread Quincey Morris
On Mar 25, 2008, at 15:01, Andy Klepack wrote: I have a subclass of NSObject that provides its own designated initializer that allows client code to configure an instance with initial values. Instances of the class itself are immutable. At the same time, instances where no initial values

Re: Best practice for overridden initializers in subclasses

2008-03-25 Thread Andy Lee
A similar question was asked recently. To paraphrase (and slightly correct) my reply: I do essentially this: - (id)init { NSLog(@%@ -- '%@' is not the designated initializer, [self class], NSStringFromSelector(_cmd)); [self release]; return nil; } You can imagine

Re: Best practice for overridden initializers in subclasses

2008-03-25 Thread Kyle Sluder
On Tue, Mar 25, 2008 at 6:01 PM, Andy Klepack [EMAIL PROTECTED] wrote: Anyone have a recommendation for the best practice in this case? Throw an exception. There's really nothing you can do at this point. --Kyle Sluder ___ Cocoa-dev mailing list

Re: Best practice for overridden initializers in subclasses

2008-03-25 Thread Quincey Morris
On Mar 25, 2008, at 16:26, Andy Lee wrote: A similar question was asked recently. To paraphrase (and slightly correct) my reply: I do essentially this: - (id)init { NSLog(@%@ -- '%@' is not the designated initializer, [self class], NSStringFromSelector(_cmd)); [self

Re: Best practice for overridden initializers in subclasses

2008-03-25 Thread Chris Suter
On 26/03/2008, at 11:09 AM, Quincey Morris wrote: 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

Re: Best practice for overridden initializers in subclasses

2008-03-25 Thread Andy Lee
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