Define a keyword for a property

Source: Internet
Author: User

1.strong: OC Object except Nsstring/block @property (nonatomic,strong) nsarray *< #model #>

2.weak: Various UI controls (but not absolute, there are controls to use the Strong property) @property (Nonatomic,weak) UIButton *button;

Basic data types such as 3.assign:cgfloat,nsinteger, enumerations, structs (non-OC Objects) @property (nonatomic,assign) CGFloat < #model #>;

4.copy: Immutable replicas (such as NSString, Nsarray, nsdictionary) are created mutablecopy: a mutable copy is created (such as nsmutablestring, Nsmutablearray, nsmutabledictionary) @property (nonatomic,copy) nsstring *< #model #>;

• @property the selection of memory management policies

1. Non-arc

1> copy: only for Nsstring/block

2> retain: OC object except Nsstring/block

3> Assign: Basic data type, enumeration, struct (non-OC object), when 2 objects are referenced to each other, one end with retain, one end with assign

2.arc

1> copy: only for Nsstring/block

2> Strong: OC Object except Nsstring/block

3> Weak: When 2 objects are referenced to each other, one end with strong, the other end with weak

4> assgin: Basic data type, enumeration, struct body (non-OC object)

Define a keyword for a property

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.