All initialized objects have at some point called super; they aren't fully
initialized otherwise. In the implementation, the non-designated initializers
typically chain to the designated initializer, which in turn chains to super's
(usually designated) initializer. So just because a designated initializer
didn't call super's designated initializer, it doesn't mean that super's
designated initialer was not invoked; it was.
On Oct 30, 2010, at 11:12 AM, Richard Somers wrote:
> 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/dave%40rudedog.org
>
> This email sent to [email protected]
_______________________________________________
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]