1. Declaration of production get and set methods
2. Generate a simple implementation of get and set methods
/*-(void) Setcar: (Car *) car{
_car = car;
}
-(Car *) car{
return _car;
}
*/
3. If you do not have a member variable of the Fame object, then he will automatically generate a member variable at the beginning of _
@property parameters are divided into 4 categories
/*
1. Parameters related to the Set method memory management
Retain: To generate a set method (Application and object type) that conforms to the memory management principle (only the old value is retain in the setter, the new value is added)
-(void) Setcar: (Car *) car{
if (_car! = car) {
[_car release];//release old value
_car = [Car retain];//retain new value
}
Assign: Direct assignment, (object type, base data type)
Copy: (explained later)
*/
2. Multithreading-related
Nonatomic: Do not generate multithreaded related code, use this can be (more efficient)
Atomic: Generate multithreaded Correlation code (this is not written by default)
In the actual development, as long as the object type of the @property are written below
3. Do you want to generate the set and get methods
ReadWrite: Readable writable property, simultaneous generation of set and get methods
ReadOnly: Read-only property, generating only get methods
4.set parameters associated with the Get method name
Setter: Sets the generated Set method name
Getter: Set the generated Get method name
@property (nonatomic,retain) car * car;
@property (nonatomic,retain) nsstring * name;
@property (nonatomic,assign) int age; int float Double Char
@property (nonatomic,assign) int weight;
@property (nonatomic,assign,readonly) int idcard;
@property (nonatomic,assign,setter = Abc:,getter = zhuanghuimei) int height;
/**
[P abc:100];
int b = [P Zhuanghuimei];
P.height = 100;//[p Abc:10];
NSLog (@ "He%d", p.height);//[p Zhuanghuimei];
P 0
*/
Changing set and get method names is a lot of variables that are used in type bool
@property (nonatomic,assign,setter = Isdeid:,getter = Isdeid) BOOL Isdeid;
Because the one that's automatically generated above is
-(void) Setisdeid: (bool) Isdeid; But previously it was said that the BOOL type is the beginning of is, so this method is used to set the is beginning, as follows:
-(void) Isdeid: (BOOL) Isdeid;
oc-@property parameters in memory management