据我所知,@synthesize实际上是在生成Getters和Setters。但是@property在做什么呢?它只是为那个很酷的@synthesize魔法函数设置参数吗?
发布于 2009-04-30 11:17:11
您可以在头文件中编写@property
@property float value;等同于:
- (float)value;
- (void)setValue:(float)newValue; 它将获取其他类信息,即您的类具有此方法
@synthesize phisicaly在类实现中创建这些方法
发布于 2009-04-30 11:34:46
@property将名称声明为属性。这意味着,可以通过点语法(object.value)访问它。
@synthetize可以看作是一个宏,它创建了getter和setter方法。知道您可以重写这些方法是很有用的,即使您输入的时候已经有了@synthetize。
发布于 2009-04-30 15:07:12
@property声明getter和/或setter
@synthesize实现了它们。
https://stackoverflow.com/questions/806379
复制相似问题