在ARC下,IBOutlets應該強還是弱? - Should IBOutlets be strong or weak under ARC?

問題:

I am developing exclusively for iOS 5 using ARC. 我正在使用ARC專爲iOS 5開發。 Should IBOutlet s to UIView s (and subclasses) be strong or weak ? IBOutletUIView (和子類)應該strong還是weak

The following: 下列:

@property (nonatomic, weak) IBOutlet UIButton *button;

Would get rid of all of this: 將擺脫所有這些:

- (void)viewDidUnload
{
    // ...
    self.button = nil;
    // ...
}

Are there any problems doing this? 這樣做有什麼問題嗎? The templates are using strong as are the automatically generated properties created when connecting directly to the header from the 'Interface Builder' editor, but why? 從“接口生成器”編輯器直接連接到標題時,模板使用的功能很strong就像自動生成的屬性一樣,但是爲什麼? The UIViewController already has a strong reference to its view which retains its subviews. UIViewController已經對其view進行了strong引用,並保留了其子視圖。


解決方案:

參考一: https://en.stackoom.com/question/WDWH
參考二: https://stackoom.com/question/WDWH
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章