@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