在OC中有兩種方式聲明和定義一種是通過設置器與訪問器的方式,還有一種是通過@property的方法,我想問通過@property的方法如何在申明文件中申明和實現(xiàn)文件中實現(xiàn),如果能給具體的例子和分析最好,謝謝
1 回答

JingJing_Laerning
TA貢獻3條經(jīng)驗 獲得超0個贊
之前我們設置一個屬性,需要寫出它的setter和getter方法,外部才可以調用?,F(xiàn)在只需要@property聲明即可。編譯器遇到@property時,會自動展開成getter和setter的聲明。
#import <Foundation/Foundation.h>
@interface Student : NSObject
@property (strong,nonatomic)int name;@end
- 1 回答
- 0 關注
- 1281 瀏覽
添加回答
舉報
0/150
提交
取消