Atomic and nonatomic are used to determine whether the compiler-generated getter and setter are atomic operations.
Atomic
When you set the @property property of a member variable, the default is atomic, which provides multithreading security.
In a multithreaded environment, atomic operations are necessary, otherwise they may cause incorrect results. Adding the Atomic,setter function will change to the following:
{Lock}
if (Property! = newvalue) {
[Property release];
property = [NewValue retain];
}
{Unlock}
Nonatomic
Prohibit multi-threading, variable protection, improve performance.
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.
Indicates that the accessor is not an atomic operation, and the accessor is an atomic operation by default. This means that, in a multithreaded environment, the parsed accessor provides a secure access to the property, the return value obtained from the picker, or the value set by the setting can be done at once, even if another thread is accessing it. If you do not specify nonatomic, the parsed accessor retains and automatically releases the returned value in the environment in which it manages the memory, and if nonatomic is specified, the accessor simply returns the value.
iOS Atomic nonatomic Differences