ios weak和strong使用的區別

strong與weak是由ARC新引入的對象變量屬性
ARC引入了新的對象的新生命週期限定,即零弱引用。如果零弱引用指向的對象被deallocated的話,零弱引用的對象會被自動設置爲nil。

@property(strong) MyClass *myObject;
相當於@property(retain) MyClass *myObject;

@property(weak) MyOtherClass *delegate;
相當於@property(assign) MyOtherClass *delegate;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章