-1

What is the difference between atomic and nonatomic properties, and what does it have to do with retaining it?

I know what @property(retain) is, defined in this website: The @property is an Objective-C directive which declares the property. The "retain" in the parenthesis specifies that the setter should retain the input value, and the rest of the line simply specifies the type and the name of the property.

So @property(retain) does what was stated above, but how does nonatomic/atomic function with the retain property?

@property(nonatomic, retain)
@property(atomic, retain)
Gabriel
  • 3,005
  • 6
  • 32
  • 44

1 Answers1

2

retain and atomic/nonatomic are orthogonal, meaning that any combination of them is valid. retain says that there is a strong link between the object and its retained property (i.e. the object referenced by the property should not be released while it is pointed to by this object). atomic/nonatomic means that the access to the property should or should not be synchronized. Here is a great explanation of the atomic/nonatomic.

Note that all of this is meaningful only when you use @synthesize.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 675,664
  • 71
  • 998
  • 1,399