Description method and sel of Study Notes of Blackhorse programmer _ oC

Source: Internet
Author: User



OC -- Description Method

 

1. The description method includes class and object methods. (Included in the nsobject class)

 

-Description (Object method)

 

2. When nslog and @ % are used to output an object, the description method of the object is called and the returned value is obtained for output.

 

+ Description (class method)

 

3. When nslog and @ % are used to output an object, the description method of the Class Object is called, and the returned value is obtained for output. The entire object is printed at one time, and the printed object uses % @.

 

4. use @ % to print an object such as ("@ %", P). By default, the output is printed as <Class Name: memory address>, although the string is also an object, however, special characters are used when @ % is used to print strings.

 

5. The + description method determines the output result of the class object, that is, the class itself.

 

6. The-description method determines the output result of the instance object, that is, the object created by person.


Sel:

 

1. the concept of SEL: SEL is actually a method packaging. It encapsulates the method into a sel type of data to find the corresponding method address. After finding the method address, you can call the method. These are runtime features. Sending a message is to send Sel, then find the address based on Sel, and call the method.

2. First, package the test method name into sel-type data;

 

3. Find the corresponding method address based on sel data;

 

4. Call the corresponding method based on the method address.

 

5. Note: There is a cache during this operation. The first search is performed one by one, which consumes a lot of performance and will be used directly later.

 

6. _ cmd: each method has an internal-cmd representing the current method.

 

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.