Can an IBOutlet to a subview be declared as strong?

Greetings,

I'm encountering a lot of conflicting information regarding the safety of making an IBOutlet to a subview as strong. According the 2015 WWDC episode 407, you're encouraged to declare IBOutlets as strong, and the exception to the rule should be that only IBOutlets which point upstream in the view hierarchy should be declared as weak. I never have the exceptional case.

However Apple's documentation https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html

states that "Outlets should generally be

weak
, except for those from File’s Owner to top-level objects in a nib file".

Is this outdated documentation? I want to keep my IBOutlets as strong because there's no retain cycle (dealloc gets called) since I never take a strong reference to any thing up in the view hierarchy, and also because I'd like the flexibility of being able to dynamically remove one or more subviews and add them in later.

If this is outdated documentation, can someone please point me to up to date documentation on this subject?

Thanks!

I need to know if the document at

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html

is outdated. I suspect that it is but I can't be certain. The wayback machine archive only visited that page starting in 2017. So that doesn't help.

KMT also pointed to the 2015 WWDC as evidence and I'm fully aware of that (see https://forums.developer.apple.com/message/292798#292798). And with the exception of a twitter conversation with the main presenter of that WWDC session, there's absolutely nothing that I can find in official Apple documentation that says strong IBOutlets are encouraged.

Can someone from Apple please answer this definitively?



Thanks!

Furthermore in that prior inconclusive thread KMT refers to:

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW6

As evidence that "As of 2015, recommended best practice from Apple was for IBOutlets to be strong unless weak is specifically needed to avoid a retain cycle."


However that section does not say that at all. It says only the top level object should be declared strong and all others as weak. The only toplevel object in my view controller is the view. All other IBOutlets are subviews. So according to the documentation I must make them weak to avoid a retain cycle? That makes no sense.

>The only toplevel object in my view controller is the view. All other IBOutlets are subviews. So according to the documentation I must make them weak to avoid a retain cycle?


If an Apple staffer doesn't chime in here, you might be able to burn a ticket w/DTS and that project to see if that channel will turn anything up.


Good luck.

Can an IBOutlet to a subview be declared as strong?
 
 
Q