When not using interface builder I always keep strong references to UI elements:
@interface myViewController : UIViewController
@property (nonatomic, strong) UILabel *folderLabel;
And then add them like this:
[self.view addSubview self.folderLabel];
where the initialiser is thus:
-(UILabel *)folderLabel{
if(!_folderLabel) {
_folderLabel = [[UILabel alloc] init];
_folderLabel.text = @"foo";
}
return _folderLabel
}
I have been told that this is bad for some reason and they should always be weak..
@property (nonatomic, weak) UILabel *folderLabel;
-(UILabel *)folderLabel{
if(!_folderLabel) {
UIlabel *folderLabel = [[UILabel alloc] init];
folderLabel.text = @"foo";
[self.view addSubview:folderLabel];
_folderLabel = folderLabel;
}
return _folderLabel
}
Is the strong reference a bad thing here?