In objective-C, after a class is correctly compiled, a variable exists in the compiled class to save information about the class. We can get this class through a common character string or through the generated object. After the class is successfully obtained, we can use it as a defined class.
Selector is similar to class. The difference is that selector is used to represent methods. In objective-CProgramDuring compilation, a unique authentication (actually an integer) is determined based on the method name (including the parameter list ), the identity creden。 of Methods declared with the same name and word in the unused classes are the same. In this way, runtime does not need to compare the method names to determine which method to execute during program execution, you can locate the corresponding method immediately by looking for an integer, and then find the entry address of the corresponding method, so that the method can be executed.
Currently, Sel, @ selector, and class are understood as reflection, and ID is understood as viod. IMP is void (* IMP) (ID, Sel ,...) the first ID and the second SEL are required. You can obtain the sel of this method by accessing _ cmd.