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 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
Abstract:
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;
@end