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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to