iOS Learning (OC language) Knowledge Point finishing
One, polymorphic
1) The popular understanding of polymorphism, that is, a method of many forms.
2) polymorphic assignment compatibility: That is, a reference to the parent class can point to the object of the child class.
3) When invoking a method in a polymorphic state, look at the object without looking at the pointer, that is, we want to see which method is executing to see which object instance we are calling this method.
4) A reference to a parent class cannot call a subclass-specific method and property and needs to be strongly turned into a subclass.
5) The use of combinatorial classes (that is, classes that contain other classes of objects), note that when using a composite class we override the initialization method of the system and instantiate the class object in the composition class so that the Member object can be manipulated directly by subsequent member methods.
6) In polymorphism we can use @class to add a reference to a class (a member in a class is not known): Prevent header files from being included with each other.
7) In polymorphism we can use Ismemberofclass to determine if the current instance is the object of that class. For example:
1-(void) Beaten: (Animal *) Animal2 { 3 //Animal is a parent class (animal has multiple classes such as dog, Cat ...). Cat is one of these subclasses4 if([Animal ismemberofclass: [Catclass]]){5 6NSLog (@"Cat");7 8 }9 [Animal action];Ten}
iOS Stage Learning 13th day notes (polymorphic)