1, readability: readonly, ReadWrite
@property (ReadWrite,....) valueType value;
This property is the default property of the variable, that is, if you (ReadWrite and readonly are not used, then your variable is the ReadWrite property), by adding the ReadWrite property your variable will have a Get method, and a set method.
Property (readonly,...) ValueType value;
This property variable means that the variable is only readable, that is, you can only use its Get method.
2, assign, setter method directly assigned value, do not perform any retain operation, in order to solve the original type and circular reference problem
3, retain, setter method to release the old value of the parameter and then retain the new value, all implementations are in this order
4, copy, setter method copy operation, and retain processing process, the first old value release, and then copy the new object, Retaincount 1. This is the mechanism introduced to reduce dependency on the context.
5, Nonatomic, non-atomic access, no synchronization, multi-threaded concurrent access improves performance.
Note that if you do not add this property, the default is two access methods are atomic transaction access. The lock is added to the owning object instance level. So it's safe not to add nonatomic to multithreading.
Attached to the net text:
Retain vs. Copy
Copy: Create an object with an index count of 1 and then release the old object
Retain: Frees the old object, assigns the value of the old object to the input object, and then increases the index count of the input object to 1
What the hell does that mean?
Copy actually creates an identical object, and retain is not:
such as a NSString object, the address is 0x1111, the content is @ "STR"
Copy to another nsstring, the address is 0x2222, the content is the same, the new object retain is 1, the old object has not changed
Retain to another nsstring, the same address (set up a pointer, pointer copy), the content of course the same, the object's retain value +1
That is, retain is a pointer copy and copy is a copy of the content.
Note: The NSString class example is wrong. NSString does not have retain, and statically allocates a memory when defined.
The difference between retain and copy in iOS