reference type properties atomic vs nonatomic

In Objective-C there is a distinction between atomic and nonatomic properties with properties being atomic by default. Swift has no such specifier. In Objective-C the implementation of an atomic property allows properties to be safely read and written from different threads. For nonatomic properties, the underlying pointer of a read value could be released when a new value is being written at the same time.


Are Swift reference type properties atomic?

Answered by SevenTenEleven in 86053022

Confirming that Swift properties are nonatomic in the ObjC sense. One reason is so you think about whether per-property atomicity is sufficient for your needs.

I assume the reference types properties in Swift are nonatomic.


I just performed a simple test which I think answers my question. I created a new Swift class inherited from NSObject and added a reference type property. In the generated header for Objective-C it shows that property declared as nonatomic.

Accepted Answer

Confirming that Swift properties are nonatomic in the ObjC sense. One reason is so you think about whether per-property atomicity is sufficient for your needs.

reference type properties atomic vs nonatomic
 
 
Q