<分区>
标签 objective-c ios xcode
<分区>
Possible Duplicate:
@property and @synthesize
当类具有属性但没有变量时,这意味着什么? 相反,我看到的是:
@interface myClass : someClass
@property (nonatomic,retain) UIButton* button;
@end
并在实现中:
@synthesize button = _button;
那么 _button
是谁?
当这样声明时,@synthesize
做了什么?
这是否意味着该类现在有一个名为 _button
的私有(private)变量?我可以将 _button
视为类的私有(private)变量吗?
最佳答案
Does this mean that the class now has a private var called _button? Can I treat _button as a private var of the class?
是的,这是 Clang 编译器的一项新功能 - 它自动为属性创建实例变量,并且 ivar 具有 @private
访问级别并且具有 _namwOfProperty
如果属性的名称是 nameOfProperty
。
关于objective-c - 对类和对象 iVar 感到困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13113905/
相关文章:
ios - 在 Main.storyboard 和 AppDelegate.h 之间建立联系
ios - 如何在 Storyboard中为新场景连接 Controller 文件
ios - NSURLSession.sharedSession 运行时显示旧数据?
ios - 未调用 MFMailComposeViewController
ios - NSString:删除 <b></b> 并为该段制作一个带有颜色的属性字符串?
ios - Xcode 11 : Changes in code not updated to app or breakpoint doesn't work