Assign : simple assignment, without changing the index count (Reference counting).
Copy : Create an object with an index count of 1 and then release the old object
: Release the old object, assign the value of the old object to the input object, and then increase the index count of the input object to 1
( nsinteger cgfloat c int, float, double, char, et cetera)
Use Copy : to nsstring
Use retain : for other NSObject and its subclasses
nonatomic , non-atomic access, no synchronization, and multi-threaded concurrent access can improve performance. Note that if you do not add this property, the default is two access methods are atomic transaction Access
1.readonly indicates that this property is read-only and is generated only Getter method is not generated Setter method.
2.readwrite , set the available access level
3.retain , which indicates that the property is assigned a value, first Release before assigning a new value to the property, the reference is added 1 .
4.nonatomic , non-atomic access, no synchronization, and multi-threaded concurrent access can improve performance. Note that if you do not add this property, the default is two access methods are atomic transaction access.
copy a and b When a piece of memory is shared, it is used. a Span style= "line-height:normal;font-family:times;" >b each has its own memory.
5. Atomic and nonatomic used to determine the getter and setter generated by the compiler is an atomic operation. In a multithreaded environment, atomic operations are necessary, otherwise they may cause incorrect results
Assign and the retain the Difference
Assignis directly assigned, which may cause1the problem when the data isint, floatwhen native types are used, you can use theAssign. retainJust as2reference counts are used, as described inretaincauses the reference count to be added1, Releasecauses the reference count to be reduced1, when the reference count is0when theDeallocthe function is called and the memory is recycled.
This article is from the "11204872" blog, please be sure to keep this source http://11214872.blog.51cto.com/11204872/1754487
iOS assign, copy, retain