If you declare a property as a weak compiler, just assign a value to the member variable, and do not handle the reference count with the Set method:-(void) SetName: (NSString *) name
{if (_name! = name) {_name = name; }}
If you declare a property as strong, the compiler actually does two things, 1, handles the reference count 2, assigns a value to the member variable set method:-(void) SetName: (NSString *) name
{if (_name! = name) {//The old object reference counter is reduced by one [_name release]; Add a new object reference count plus one [name retain]; Assign a value to a member variable _name = name; }
}
The following content is reproduced, the source is unknown. Assign: Specifies the setter method with a simple assignment, which is the default action. You can use this property for scalar types, such as int. You can imagine a float, which is not an object, so it can't be retain, copy.
Retain: Specifies that the retain should be called on a later object, and the previous value sends a release message. You can imagine a nsstring instance, which is an object, and you might want to retain it.
Copy: Specifies that a copy of the object (deep copy) should be used, and the previous value sends a release message. Basically like retain, but without increasing the reference count, it is allocating a new piece of memory to place it.
ReadOnly: Only getter methods will be generated and no setter method is generated (getter methods do not have a get prefix).
ReadWrite: The default property will generate getter and setter methods with no extra parameters (the setter method has only one parameter).
Atomic: The default property for an object is that the Setter/getter generated method is an atomic operation. If there are multiple threads calling the setter at the same time, there will not be one thread executing the setter all the way before the other thread starts executing the setter, related to the method's tail and end lock.
Nonatomic: The atomicity of Setter/getter is not guaranteed, and data may be problematic in multithreaded situations.
Strong and weak