Properties in Objective C [duplicate]
Possible Duplic开发者_StackOverflowate:
Atomic vs nonatomic properties
I am a beginner in objective-c. Can you tell me what is the function of following line in the code:
@property(nonatomic , retain) UITextField *userName;
This creates a property called userName
of type UITextField
for instances of whatever class this code is in. The (nonatomic, retain)
code tells the compiler that the property will be retained every time it is accessed, and to make it thread-safe (nonatomic
).
If the property is implemented with an @synthsize
command, the compiler will create getter and setter methods for you, and it will make sure the getter retains your property.
Also, make sure to surround code in your questions, answers and comments with backticks like `. This will format them as code with appropriate coloring, font and highlighting.
精彩评论