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)