When you create a subclass, if you implement an initializer, you must definitely call the initializer of the superclass, and you must specify at least one assigned initializer, although this may just be your override of the superclass.
As part of the initialization of your subclass, you must call one of the initializers assigned to the superclasses.
Class documentation should designate designated initializers. If not, the designated initializer is usually considered the most specific initializer (which takes most arguments) provided by the superclass.
See "Objective-C Programming Language: Object Selection and Initialization" for details . [Note: As of December 2013, this content is no longer available through the Apple doc. Which language link has been replaced by more task-oriented textbooks and conceptual documentation.]
Regarding your specific questions:
Why is this? For the superclass to be able to initialize its state. You can continue and initialize the state that you add above and above what the superclass provides.
Why does calling super-init from a subclass of initWithFrame lead to an infinite loop? Since for NSView , -init not a designated initializer, although it is NSObject 's, therefore NSView overrides it to call the designated initializer -initWithFrame: If you called -init from your -initWithFrame: you now have -initWithFrame: call to -init calling -initWithFrame: call to -init: calling ...
Does it mean...? No, because it is not required. You should understand the actual documentation, not firsthand.
source share