1. First talk about @property, this is the key word after iOS6. After you declare a property with it, the compiler automatically generates a setter and getter method for you.
@property (nonatomic, retain) NSString *name;
The setter method is as follows:
-(void) SetName: (nsstring*) _name{
First, determine if it is consistent with the old object, and if it is inconsistent, assign the value.
Because if it is an object, the code in the if will cause an extreme situation: when the name of the retain is 1 o'clock, so that the set operation let the instance name early release, and do not reach the assignment purpose.
if (name! = _name) {
[Name release];
name = [_name retain];
}
}
Getter methods are as follows
-(NSString *) name
{
return _name;
}
2. @synthesize declared in. m
@synthesize name = _name;
This way self.name = otherstring and name = Otherstring can be compiled correctly, but the former invokes the setter method for a copy, which is not equivalent to Assign/weak.
[email protected] and @property