Objective-c syntax of the @porpetry keyword

Source: Internet
Author: User

1, Introduction:

The property is a objective-c keyword, used in pairing with @synthesize , to allow the compiler to automatically generate a method declaration with the same name as the data member. @synthesize is the implementation that is used to generate the corresponding declaration method.

Syntax format for 1.1 property:

@property (parameter 1, Parameter 2) type name;

Here are the main parameters, the following three kinds:

Setter/getter Method (assign/retain/copy)

Read-write properties (readwrite/readonly)

Atomicity (nonatomic)

1.2 Three ways to use

The assign/retain/copy represents the way in which the value is assigned.

the ReadOnly keyword means that the setter will not be generated, so it cannot be used in combination with Copy/retain/assign .

The default value for Atomicity is Atomic, and the Read function is atomic.

1.2.1 Copy/reain/assign in which to select a setter to determine how the property handles this property. The NSObject object is used in this way.

1.2.2 Some special objects, such as nssstring, use copy.

The 1.2.3 assign keyword represents the setter's direct assignment, rather than copying or preserving it. For basic data types, such as Nsinteger and cgfloat, or types that you do not directly own, such as delegates.

Objective-c syntax of the @porpetry keyword

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.