The general recommendation was to use weak IBOutlet for the subviews. But now in iOS 6, views are no longer purged with memory warning, so is there any real practical difference between declaring an outlet as weak vs strong? I mean practical and not theoretical.
2
votes
views are no longer purged with memory warning,means?Can you explain
– Lithu T.V
That's what the documentation states: developer.apple.com/library/ios/#documentation/uikit/reference/… search for viewDidUnload part.
– Enzo Tran
To my knowledge you should make the IBOutlets weak properties, except for the main view of the view controller.
– Javier Quevedo
Subviews are retained by their superview. So the question is if you need a reference to the view if it's not added to a view. If you intend to remove the view from its superview while keeping a reference to it, use strong.
– Matthias Bauch
@MatthiasBauch and JavierQuevedo-Fernández: Yes I already know all that theory. But from the practical point of view, and for consistency, I see no point declaring outlets as weak anymore. I would just declare all outlets as strong (except if it's cyclical reference), that way I won't have to worry about if I remove it from superview later. Right now there are no real advantages of using weak, compared to iOS 5 when if helps you avoid having to nil out the subviews in viewDidUnload.
– Enzo Tran