Question on overriding initializers


#1

The last bullet item on the top of page 52 states:

“If a class declares a designated initializer that is different from its superclass, the superclass’s designated initializer must be overridden to call the new designated initializer”.

I am wondering why this statement explicitly mentions this need only for the designated initializer of the superclass (rather than all initializers of the superclass). When we define a new class, shouldn’t we consider whether we need to override ALL initializers of its superclass, rather than just considering the need to override the designated initializer of the superclass? i.e., Can’t any of these inherited initializers be potentially called by a class’s clients, thus leaving the object in a partially un-initialized state (assuming that a default value of zero for the new class’s data members is not acceptable)?

This just seems like a specific instance of a more general rule: When implementing a new class, we should consider whether the behavior of any inherited method will be acceptable for the derived class, or whether instead the inherited method should be overridden.

What am I missing here? i.e., Why did this rule only mention the superclass’s designated initializer rather than all inherited initializers?

Thanks to all for your feedback!


#2

I figured this out now…

If client code calls an initializer for a derived class instance and that initializer is defined in the superclass but is not the designated initializer of the superclass, that initializer will call the designated initializer of the superclass. But, since the designated initializer of the superclass will be overridden in the derived class (assuming the recommendation in question is followed), then the call (i.e., “message”) will actually be directed to implementation in the derived class. Thus, the initializer will then be able to initialize any new data members of the derived class.