0

Possible Duplicate:
what is diff. b/w @property (nonatomic,assign) and @property (nonatomic,retain)

I know it is used to inform the compiler to generate the getters and the setters automatically, But I want to know what role does nonatomic, retain play here ? It would be helpful if anyone gives a clear explanation with an EXAMPLE

Community
  • 1
  • 1
  • see this http://stackoverflow.com/questions/3375063/what-is-the-use-of-property-nonatomic-retain-statement-in-the-application – Vin May 23 '11 at 07:10
  • Also: [Retain attribute with property and synthesize](http://stackoverflow.com/questions/1980488/), [Why does this property need the retain?](http://stackoverflow.com/questions/876622/), [How is retain setter implemented?](http://stackoverflow.com/questions/3924463/) – jscs May 23 '11 at 07:20

1 Answers1

1

nonatomic means that when the property getters and setters are generated via @synthesize, they will not be implemented using any locking. So, when accessing the value it can be changed at any time and the getters and setters do not block; multiple reads/writes of the property are not serialized.

Retain will increment the retain count of the property by 1 so that it will not release when it goes out of scope. In order to free the allocated memory for the property you would then release it in dealloc

jcpennypincher
  • 3,970
  • 5
  • 31
  • 44