Using assign: for underlying data types (Nsinteger) and C data types (int, float, double, char, etc.)
Using copy: On NSString
Use retain: For other nsobject and its subclasses
Assign is a simple assignment that does not change the reference count, so use the underlying data directly
Copy is a direct copy of the content and becomes a new object.
Retain frees the old object, assigns the value of the old object to the new object, and adds 1 to the reference count of the new object
Retain is a pointer copy copy, which allocates new memory to the content copy and releases the old object before copying.
In Arc, retain and strong are consistent (declared as strong references); Assign and weak are basically the same (declared as weak references)
======= Weak references (weak,assign), and the difference =======================================
The reason for the weak reference: to prevent cyclic application.
Strong reference loops: The A object strongly references the B object, and the B object also strongly references a. Because both are strong references, that is, whether a is B is to be in the other side of the reference is broken before it can be destroyed, but to break the reference, you must destroy the object. There will be such an impasse, in order to avoid this situation, there should be an object "weakness" to make it a "weak reference". The difference between weak and assign is that when the object is destroyed, weak will put the pointer to nil, and assign will not, so assign will cause wild pointers, more dangerous.
More commonly, a reference between a parent-child view in a view that is strongly referencing a child view, and a child view that has a weak reference to the parent view.
= = =Atomic and nonatomic====================================================
Atomic is a thread-protection technique used by OBJC, basically to prevent the data from being read by another thread when the write is not completed. This mechanism is resource-intensive, so nonatomic is a very good choice on small devices such as the iphone, if there is no communication programming between multiple threads.
The difference between copy,retain,strong,assign,weak in iOS and the use