ARC and IBOutlet - strong vs weak......
ARC and IBOutlet - strong vs weak......
- Subject: ARC and IBOutlet - strong vs weak......
- From: Dave <email@hidden>
- Date: Fri, 04 Dec 2015 14:16:42 +0000
Hi All,
This is for Mac, not iOS.
Under ARC, should an IBOutlet be strong or weak?
If strong, do I need to set the outlets to nil in the corresponding dealloc method?
I did a google for this and are many conflicting answers to this question but one with a lot of votes on Stack Overflow is this:
The current recommended best practice from Apple is for IBOutlets to be strong unless weak is specifically needed to avoid a retain cycle. As Johannes mentioned above, this was commented on in the "Implementing UI Designs in Interface Builder" session from WWDC 2015 where an Apple Engineer said:
And the last option I want to point out is the storage type, which can either be strong or weak. In general you should make your outlet strong, especially if you are connecting an outlet to a subview or to a constraint that's not always going to be retained by the view hierarchy. The only time you really need to make an outlet weak is if you have a custom view that references something back up the view hierarchy and in general that's not recommended.
I asked about this on Twitter to an engineer on the IB team and he confirmed that strong should be the default and that the developer docs are being updated.
Thanks a lot,
Cheers
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden