@interface fooViewController : UIViewController { UILabel *fooLabel; } @property (nonatomic,weak)IBOutlet UILabel *fooLabel; @end但也有人放在ivar
@interface fooViewController : UIViewController { IBOutlet UILabel *fooLabel; } @property (nonatomic,weak)UILabel *fooLabel; @end甚至兩個地方都放的
@interface fooViewController : UIViewController { IBOutlet UILabel *fooLabel; } @property (nonatomic,weak)IBOutlet UILabel *fooLabel; @end這些程式碼都不會出錯,不過我還是想知道到底放在哪裡最好,查到了這一篇講得很清楚。
放在property比較有彈性,且編譯的速度快些,官方文件也是推薦放在property,有興趣的人可以看看。