iOS Review notes 6:property detailed

Source: Internet
Author: User

@property type XXX can automatically generate a type _xxx; member variable;
The corresponding setter and getter methods are also generated.
You can control the generation of getter and setter methods through the following four types of parameters.
1 set method Memory management parameters
1.1 Assign: Default value, direct assignment, for the underlying data type
1.2 Retain:release old value, retain new value, and then assigns value
1.3 Copy:release old value, copy new value


2 whether to generate parameters for setter methods
2.1 ReadWrite: Default value while generating Setter,getter method declaration and implementation
2.2 ReadOnly: Only the Get method is generated


3 multi-line loads lock control parameters
3.1 natomic: Default value, lock in multiple threads
3.2 nonatomic: No lock in multi-thread, high performance, recommended use


4 Method Name parameter (typically used only to change the getter method of a Boolean type)
4.1 Getter:getter Method Name
4.2 Setter:setter Method Name (note that there must be a colon)


* Four types of parameters can exist simultaneously as long as there is no function conflict.


For example:
@property (nonatomic, assign, readwrite) int age; @property (nonatomic, getter = Isrich) BOOL rich; @property (nonatomic, Retain) book* book;


iOS Review notes 6:property detailed

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.