I have a class (a subclass of NSObject) that requires several parameters to be properly initialized. I have a -(id) initWithParams... method defined. I can't have -init invoke -initWithParams (as a designated initializer) because the object instance wouldn't be set up properly. I am wondering what is the best practice regarding -(id) init in such a case.

1) Do I just let -init dangle (so to speak)? and then if I ever forget that the object needs special initialization and instead call - init, the code will end up failing down the line somewhere where those initialization parameters matter...

2) Do I define a -(init) method and have it throw an exception? so that I'll find out right away if some code invokes -init rather than - initWithParams....

3) Is there some way to tell the compiler to ignore the superclasses's -init for the subclass so that I get a compile time error? This would be my preferred outcome.

Thanks in advance for your thoughts,
--Stuart
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to