Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: expected a property attribute before 'atomic'

Tags:

ios

ipad

I get the following exception on this line:

@property (atomic ,retain) NSString *title;

error: expected a property attribute before 'atomic'

What does that mean ?

like image 357
user680406 Avatar asked Dec 27 '25 16:12

user680406


1 Answers

There is no keyword atomic to use in a declared property. A property declared is by default behaving "atomic" so you don't have to set it explicitely. You just change the default behaviour by adding nonatomic. As this is a compile time directive it is not needed to change this value during runtime, making "atomic" needless.

Quoting Apple's The Objective-C Programming Language / Declared Properties

Atomicity

You can use this attribute to specify that accessor methods are not atomic. (There is no keyword to denote atomic.)

nonatomic Specifies that accessors are nonatomic. By default, accessors are atomic. Properties are atomic by default so that synthesized accessors provide robust access to properties in a multithreaded environment—that is, the value returned from the getter or set via the setter is always fully retrieved or set regardless of what other threads are executing concurrently. For more details, see “Performance and Threading.”

like image 166
Nick Weaver Avatar answered Dec 30 '25 06:12

Nick Weaver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!