代碼1在Objective-C中編寫@property指令的位置?
@interface Rectangle : NSObject
{
int width,height;
}
@property int width,height;
碼2
@interface Rectangle : NSObject
@property int width,height;
{
int width,height;
}
誰能告訴我,什麼是他們之間有什麼不同?並在@property
我已經把int
width
和height
。爲什麼我們需要在大括號中再次聲明它?
更新: 我使用的是osx 10.8 64bit。
這兩者是否存在問題?或者您不確定爲什麼需要將其聲明爲屬性並放在括號中? – 2012-07-31 18:16:05
如果我把{初始寬度,高度},我會得到一些種類的錯誤。 – Ben 2012-07-31 18:18:56
如果你把'{int width,height;}'你得到什麼錯誤?嘗試更具體。 – 2012-07-31 18:20:25