Objective-C class selector

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.