开发者

Properties in Objective C [duplicate]

This question already has answers here: Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜