Nonatomic: Non-atomic access, non-synchronous, multi-threaded concurrent access improves performance. If this attribute is not added, the default is two access methods are atomic transaction access.
(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. )
Assign: Simple assignment, not changing index count
For the underlying data type (Nsinteger) and the C data type (int, float, double, char, and so on),Failure to do so may result in memory leaks. For example, if you use malloc to allocate a piece of memory and assign its address to pointer A, then if you want pointer b to share this memory, then say a assigns to (Assgin) b. At this point the assgin is used, and a and B point to the same piece of memory. But now the problem arises, and when a no longer needs this memory, can it be released directly? Must not be, because a does not know whether B is still using this memory, if a is released, then B in the use of this memory when the program crash out.
Copy: Create an object with an index count of 1 and then release the old object
To NSString
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
For other NSObject and its subclasses
The difference between copy and retain:
Copy is to create a new object, retain is to create a pointer to reference the object Count plus 1.
Eg: an NSString object with an address of 0x1111 with the content @ "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.
More code Examples
The difference between Nonatomic,assign,copy,retain in objective-c