Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of @property (nonatomic, retain) statement in the application ?

Tags:

iphone

i m a beginner iphone developer and i want to know about what is the use of @property (nonatomic, retain) statement with example , any body can give me any answer ?

like image 344
user407063 Avatar asked Jul 30 '10 20:07

user407063


People also ask

What does Nonatomic mean in Objective C?

Nonatomic means multiple thread access the variable (dynamic type). Nonatomic is thread unsafe. But it is fast in performance.

What is retain and assign in IOS?

retain = strong -it is retained, old value is released and it is assigned -retain specifies the new value should be sent -retain on assignment and the old value sent -release -retain is the same as strong. -

What is strong and Nonatomic in Objective C?

nonatomic property means @synthesize d methods are not going to be generated threadsafe -- but this is much faster than the atomic property since extra checks are eliminated. strong is used with ARC and it basically helps you , by not having to worry about the retain count of an object.

What does non Atomic mean?

In mathematics, more precisely in measure theory, an atom is a measurable set which has positive measure and contains no set of smaller positive measure. A measure which has no atoms is called non-atomic or atomless.


2 Answers

@property tells Objective-C to generate the getters and setters for this member variable when it is @synthesize'd in the implementation class. The retain parameter says that the generated setter should pass the retain message to the parameter being set. nonatomic means that atomicity of getting and setting the variable is not guaranteed.

like image 123
Damien Avatar answered Nov 15 '22 00:11

Damien


Apple has a lot of examples in the Declared Properties section of their Objective-C Programming Language guide. Definitely worth reading through.

like image 41
Alex Reynolds Avatar answered Nov 14 '22 22:11

Alex Reynolds