A class can have many initializers. According to the documentation for NSObject, by convention the initializer that includes a message to super (usually the one with the most arguments) is the designated initializer for the class. This initializer should begin by sending a message to super to invoke the designated initializer of the superclass.

On page 192 of Cocoa Programming for Mac OS X, Third Edition, by Hillegass there is an initializer for a NSWindowController subclass that looks something like this (altered slightly).

- (id)init // NSWindowController subclass designated initializer
{
     self = [super initWithWindowNibName:@"MyNibFile"];
     if (self) {
         // Initialization code.
     }
     return self;
}

This is the only initializer this subclass implements and by convention it is the designated initializer because it calls super.

But note that the initializer does not call the designated initializer of the superclass which would be 'initWithWindow:'. It calls 'initWithWindowNibName:' instead, which is not the designated initializer of the superclass.

So my question is, what are the implications if the designated initializer does not call the designated initializer of the superclass but calls one of the other initializers instead?

--Richard Somers

_______________________________________________

Cocoa-dev mailing list ([email protected])

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