@property (nonatomic, assign) NSString *title;
What is the difference between assign,copy,retain?
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
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
The difference between weak and strong:
The difference (weak and strong) is that when an object no longer has a strong type pointer pointing to it, it is freed, even if there is a weak pointer to it.
Once the last strong pointer is left, the object will be released and all remaining weak pointers will be cleared.
There may be an example to describe it as appropriate.
Imagine our object is a dog, the dog wants to run Away (be released).
The strong type pointer is like a tethered dog. As long as you hang the dog with a leash, the dog will not run away. If there are 5 people holding a dog (5 strong pointers pointing to 1 objects), the dog will not run away unless 5 of the ropes fall off.
The weak type pointer is like a child pointing at the dog and shouting: "Look!" A dog is there. "As long as the dog is kept tied, the child can see the dog, and the (weak pointer) will always point to it. As long as the dog's leash comes off, the dog will run away, no matter how many children are watching it.
As long as the last strong pointer no longer points to the object, the object is freed and all weak pointers are cleared.
Use assign: for underlying data types (nsinteger,cgfloat) and C data types (int, float, double, char, and so on)
Using copy: On NSString
Use retain: For other nsobject and its subclasses
Nonatomic Keywords:
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 Assign,copy,retain in iOS and the difference between weak and strong