Can an IBOutlet to a subview be declared as strong?


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

states that "Outlets should generally be

, 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?


Accepted Reply

This thread has been deleted

>I assume that Apple vets every single WWDC talk that is given. To developers what is stated in a WWDC session is the ultimate truth (unless publically retracted later). It's an incredibly strong and shocking recommendation that Apple gave in the 2015 WWDC session 407.

Apple vets every single WWDC talk but they don't vet their own documentation?

Unless the storage type you choose results in a bug, depending on what you are doing, then arguing about what is "right" is kind of pointless as already mentioned. But for whatever it is worth, most recent Apple sample code I've seen uses weak for IBOutlets. Not trying to start a fight, but it doesn't really matter unless it really matters. And when it really matters, hopefully you'll know it.

Copyright (C) 2017 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information

The detail view controller navigated to from our main and results table.

#import "APLDetailViewController.h"
#import "APLProduct.h"

@interface APLDetailViewController ()

@property (nonatomic, weak) IBOutlet UILabel *yearLabel;
@property (nonatomic, weak) IBOutlet UILabel *priceLabel;



I need to know if the document at

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 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?


Furthermore in that prior inconclusive thread KMT refers to:

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.