I am developing exclusively for iOS 5 using ARC. Should IBOutlet
s to UIView
s (and subclasses) be strong
or weak
?
While the documentation recommends using weak
on properties for subviews, since iOS 6 it seems to be fine to use strong
(the default ownership qualifier) instead. That's caused by the change in UIViewController
that views are not unloaded anymore.
That said, I am torn between using
@property (nonatomic, weak) IBOutlet UIButton *button;
and
@property (nonatomic) IBOutlet UIButton *button;
in iOS 6 and after:
Using weak
clearly states that the controller doesn't want ownership of the button.
But omitting weak
doesn't hurt in iOS 6 without view unloading, and is shorter. Some may point out that is also faster, but I have yet to encounter an app that is too slow because of weak
IBOutlet
s.
Not using weak
may be perceived as an error.
Bottom line: Since iOS 6 we can't get this wrong anymore as long as we don't use view unloading. Time to party. ;)