問題:
I am developing exclusively for iOS 5 using ARC. 我正在使用ARC專爲iOS 5開發。 Should IBOutlet
s to UIView
s (and subclasses) be strong
or weak
? IBOutlet
到UIView
(和子類)應該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