【发布时间】:2012-07-31 18:14:42
【问题描述】:
代码1
@interface Rectangle : NSObject
{
int width,height;
}
@property int width,height;
code2
@interface Rectangle : NSObject
@property int width,height;
{
int width,height;
}
谁能告诉我,他们之间有什么不同?在@property 中,我已经为width 和height 添加了int。为什么要在大括号中再次声明?
更新: 我使用的是 osx 10.8 64bit。
【问题讨论】:
-
其中一个是否有问题,或者您只是不确定为什么需要将其声明为属性并在括号中?
-
如果我输入 {init width,height},我会得到一些错误。
-
如果你把
{int width,height;}放在哪里你会得到什么错误?尝试更具体。 -
区别在于第二个是非法的。
标签: objective-c properties compiler-directives