IOS intermediate-when to use copy, strong, weak, assign keywords to define attributes, iosassign

Source: Internet
Author: User

IOS intermediate-when to use copy, strong, weak, assign keywords to define attributes, iosassign
The parent class pointer can point to the subclass object // define the block alias. Typedef void (^ LYItemOption )();

@ Interface LYItemArrow: LYItem
@ Property (nonatomic, strong) Class desController; @ property (nonatomic, copy) LYItemOption option; 1. strong: The OC object except NSString \ block @ property (nonatomic, strong) NSArray * <# model #>; 2. weak: Various UI controls (but not absolute, some controls must use the strong attribute) @ property (nonatomic, weak) UIButton * button; 3. assign: CGFloat, NSInteger, and other basic data types, enumerations, struct (non-OC objects) @ property (nonatomic, assign) CGFloat <# model #>; 4. copy: creates an unchangeable copy (such as NSString, NSArray, and NSDictionary) mutableCopy: Creates a mutable copy (such as NSMutableString, NSMutableArray, NSMutableDictionary) @ property (nonatomic, copy) NSString * <# model #>; • @ selection of the property Memory Management Policy • 1. non-ARC • 1> copy: used only for NSString \ block • 2> retain: OC object except NSString \ block • 3> assign: basic data types, enumerations, and struct (non-OC objects). When two objects reference each other, one end uses retain and the other end uses assign • 2. ARC • 1> copy: used only for NSString \ block • 2> strong: OC objects other than NSString \ block • 3> weak: When two objects reference each other, one end uses strong, one end uses weak • 4> assgin: basic data type, enumeration, struct (non-OC object)

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.