41. Define the role of ISA in succession
- 1, in Objective-c, each object is hidden a data structure ISA pointer
- 2, the ISA pointer to the object's class, this class is also an object, has its own rights.
- 3, in Objective-c, each object also retains a pointer to a superclass, through which the pointer can dispatch its own methods and scheduling base class.
42. Using categories and protocols to implement a mechanism similar to multiple inheritance
- 1, categories, the implementation of the class-related methods of modularization, the different classes of methods assigned to different file.
- 2, the class can overload the method of the original class, but it is not recommended to do so, the result is no longer access to the original method, if it is really overloaded, the correct choice is to create a subclass.
- 3, and the ordinary interface is different, the implementation of the class file can not implement all the declared method, as long as not to call it.
- 4, the agreement is a series of methods that do not belong to any tired list, wherein the declared method can be implemented by any class. Protocol (PROTOCOL) is not a real class, it can only declare methods and cannot add data.
43. Category and class extensions are continuation extensions of class inheritance.
44, inherit the implementation of the base class do not forget to call super.
- 1. Call the base class method to use the services provided by this class.
- 2. Override the method of the base class in order to introduce your own code into the defined program model.
- 3. If you intend to supplement the behavior implemented by the base class, call Super.
- 4. Do not call super if you intend to replace the behavior implemented by the base class.
Writing high-quality Code-OC 6th Chapter inheritance and object-oriented design