The inheritance mechanism in OC is single-inheritance, and a subclass can have only one parent class
OC supports multilayer inheritance, a inherits Nsobject,b inheritance A which is called multi-layer inheritance
The order of method calls in the inheritance system
1. Find in your own class
2, if not, go to the parent class to find
3, if not in the parent class, go to the parent class
4, if the parent class also does not have, it also looked up until the base class (NSObject) was found
5, if NSObject did not have an error
Only inherit nsobject so this object has the ability to create objects
NSObject is the base class for most classes (root Class),
/*
When Class A inherits Class B, then class A has all the member variables and methods in class B
1. Inheritance Benefits: Code Reuse
2, Inheritance disadvantage: The change of the parent class affects all the subclasses, the child class and the parent class coupling degree is very high
Class A inherits Class B for the purpose of using member variables and methods in class B
Usage scenarios:
When we find that a class is another class, we can use inheritance, such as the student is a person, then when defining the student class, we can let the students inherit the human
3, when the subclass does not want to use the parent class method, then the parent class method overrides
OC Basic Notes-Inheritance (Guangzhou black horse Phase I)