Can you explain What is nonatomic in iphone
What is nonatomic ?
hello friends,
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Chintan RathodPosted Dec 5, 2012, 12:03 PM
Basically, if you say nonatomic, and you generate the accessors using @synthesize, then if multiple threads try to change/read the property at once, badness can happen. You can get partially-written values or over-released/retained objects, which can easily lead to crashes. (This is potentially a lot faster than an atomic accessor, though.)
If you use the default (which is atomic; there's no keyword for this), then the @synthesized methods use an object-level lock to ensure that multiple reads/writes to a property are serialized. As the Apple docs point out, this doesn't mean the whole object is thread-safe, but the property reads/writes are.
Of course, if you implement your own accessors rather than using @synthesize, I think these declarations do nothing except express your intent as to whether the property is implemented in a threadsafe manner.
Reference:
Apple Docs
Thanks