10-Dynamic type checking
1. Dynamic binding
1) The invocation of a method in OC is not determined by the compiler, but is determined by the runtime
2) There are no method calls in OC, only messages are received. The message is generally called a selector
2. Dynamic type checking
The ability of an object to acquire a type at run time is called introspection, and if you want to know whether an object has a specified method in your code, you can use:
1) determine type or parent class type
-(BOOL) Iskindofclass: (Class) OBJ
Determines whether an object has an object that is instantiated by a class or its subclasses
2) Only judging the type
-(BOOL) Ismemberofclass: (Class) obj
Determines whether an object is instantiated by a class
3) decide whether to subclass
+ (BOOL) Issubclassofclass: (Class) obj
Determine whether a class is a subclass of a class
4) Determine if you can respond
-(BOOL) Respondstoselector: (SEL) Selector
5) Determine if this method is available
-(BOOL) Instancesrespondtoselector: (SEL) Selector
6) Response method
-(ID) Performselector: (SEL) Selector
7) Respond to methods with parameters
-(ID) Performselector: (SEL) Selectorwithobject: (ID) obj
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
O-c related -10-dynamic type checking