tags:

views:

57

answers:

1

Possible Duplicate:
Objective-C properties: atomic vs nonatomic

By default all properties in Objective-C are atomic. If I need nonatomic I have to declare it. But I wonder why should I ever use nonatomic? Even if my applications are not multi threaded, atomic seems like the way to do it. What are the advantages of nonatomic?

+2  A: 

A short answer is performance. If you declare properties as atomic, the synthesized accessors will use locks to ensure that values are fully retrieved and set. If you don't need this, e.g., your application is single-threaded, you're incurring a performance penalty for those locks without getting a benefit.

James Huddleston
And therefore setting properties to nonatomic without profiling counts as premature optimisation.
JeremyP