The definition of attributes and the use of @synthesize

Source: Internet
Author: User

1. Properties typically refer to certain data that is encapsulated or stored by an object. It can be a flag (such as a name or color), or it can be a relationship to one or more other objects.

2. The basic declaration of a property uses the @property compiler directive, followed by the type information and name of the property. You can also use custom options to configure properties to define how the access method behaves, whether the property is a weak reference, and whether it is read-only.

3.

If you want instance variables to have different names, you can bypass auto-compositing and explicitly synthesize attributes. Use compiler directives in the class implementation to have the @synthesize compiler generate access methods, as well as special named instance variables. For example:

@synthesize enabled = _isenabled;

Simply put, @synthesize's role is to redefine the attribute variables you create automatically when you define attributes in the interface section of the implementation section.

The definition of attributes and the use of @synthesize

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.