IOS OC avoids declaring attributes in a taxonomy

Source: Internet
Author: User

a description

Although it is technically possible to declare attributes in a taxonomy, this practice should be avoided because, except for the class-continuation classification (extension), other classifications cannot add instance variables to the class, so they cannot synthesize the instance variables required to implement the properties.


The correct approach is to define all attributes in the main interface, which is the only place where you can define instance variables. The attribute is simply the "syntactic sugar" used to define the instance variable and the associated access method, and all should follow the same rules as the instance variable.


As for the classification mechanism, it should be understood as a means of extending the functionality of the class rather than encapsulating the data


Two summary

All properties used to encapsulate data are defined in the main port

In other categories outside of class-continuation, you can define access methods, but try not to define attributes



IOS OC avoids declaring attributes in a taxonomy

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.