Read effective Objective C Summary (ii)

Source: Internet
Author: User

    1. Features of the OC compiler: When declaring a member variable, the compiler produces a hard-coded offset that represents the length of the start address of the variable distance from the memory area where the object resides. OC takes this offset as a special variable for the class object, and when it is found in runtime, it can always generate the correct offset.

    2. @property properties: Without any manual action, this property first automatically generates getter and setter methods, and generates member variables for the corresponding property "_ Field"

    3. The semantics of memory management in @property:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/71/B3/wKiom1XW1i_TE_HeAAQcTw1X8JI186.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiom1xw1i_te_heaaqctw1x8ji186.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/71/AF/wKioL1XW2EKA3shhAAKnsIq6sPU973.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiol1xw2eka3shhaaknsiq6spu973.jpg "/>

4. About the principle of using point syntax: In the initialization method or DEALLOC, use member variables, do not use point syntax (do not know why), access member variables inside the object, write data using point syntax, so as to facilitate the expression of memory management semantics, read data when possible to use _ member variables.

5. In NSObject, determine whether two objects are equal: Call method Isequalto, its algorithm is divided into three steps:

First, determine if the pointers to two objects are the same

Second, if the pointers are different, determine whether the two classes are the same

Third, if the class is the same, then you can determine whether each property is the same

When these judgments are finished, the hash code is judged to be the same

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/71/B1/wKioL1XW_B-jmCe0AACTOAXsTM8772.jpg "title=" 3.jpg " alt= "Wkiol1xw_b-jmce0aactoaxstm8772.jpg"/>

Read effective Objective C Summary (ii)

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.