SELof the 1.SEL typedefinition2. Method ofStorage location
- The list of methods for each class is stored in the class object
- Each method has an object of the corresponding sel type
- The address of the method can be found based on a Sel object, and the method is called
of the 3.SEL objectCreate
Way One:
method Two: convert a string into SEL type data
4. Use the SELCalling Methods
- The invocation of the Invisible parameter method:
①: Wraps the method (test) into the SEL type data;
②: The corresponding method address is found according to the SEL data; ③: The corresponding method is called according to the method address;
After integration:
Equivalent to:[P test];
- Invocation of methods of tangible parameters
Equivalent to:[P test3: @ "abc"];
5.SEL ofOther usesAndUse note
- SEL type data cannot be printed directly, it needs to be nsstringfromselector (_cmd), converted to string type, printed.
- Each method hides a sel-type data _cmd, and the _cmd here represents the current Method!
- Attention point: dead Loop
- Actually sending the message to the object is to send the SEL;
Dark Horse programmer----SEL