Reputation: 77641
When creating UIs in IB I have often used buttons that have an action but there is no reason for the view controller to access this button.
The button text never changes, the button image never changes, it never moves, etc...
Because of this I don't give it an IBOutlet property and I don't connect it up to anything in the VC (other than the action of course).
There is a similar question on SO that I've read and the arguments on there go into memory management issues. That question is from early 2011, before ARC. Given that all my IBOutlet properties are weak anyway the memory is dealt with by their superview not by the view controller. So the issues mentioned in that question are now moot.
Is there a reason to connect them up now? Should they always have a connection? If so, why?
Upvotes: 2
Views: 162
Reputation: 5812
Answer is NO.
But here's a valuable tip, if someone sees this question/answer and goes gung ho and deletes all the unused IBOutlets.
If you remove an IBOutlet for a UIElement, make sure that the UIElement in the IB is not referencing to the now non-existant outlet. Otherwise, you'll have some weird crashes, that'll take quite some time to be resolved.
This is an issue that has had me in a soup many times. I am not sure if this has been fixed in the latest versions of Xcode, but its safer to check.
Upvotes: 1
Reputation: 108111
Short answer: no.
IBOutlet
s are needed to refer to elements of the UI.
If you don't need to access to such elements, you don't have to connect them with a IBOutlet
Upvotes: 7