Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should IBOutlets be strong or weak under iOS9?

I am just reading about memory management practices in ARC as per new guideline it is now best practice to use Strong for IBOutlets.

Can some one confirm this as i was using weak property for all IBOutlets UIKit object and strong for Foundation framework objects previously.

So what is the new memory management practices in iOS9 and Xcode 7?

Reference :

https://www.invasivecode.com/weblog/storyboard-strong-iboutlet-scene-dock/

like image 248
SwiftLearner Avatar asked Nov 30 '25 23:11

SwiftLearner


1 Answers

It's not a matter of OS version, it is about ARC. IBOutlets should be weak.

Generally the argument they're making is one of performance. However, a stronger principle is that you shouldn't have strong references to things that you didn't directly create. In theory those objects can I go away at any time and it should nil out automatically. Anytime someone makes an argument about performance related to something like an IB outlet it smacks of pre-optimization. So if you measure a performance problem related to the nilling out of objects then sure make it strong otherwise it should remain weak.

like image 197
Cameron Lowell Palmer Avatar answered Dec 03 '25 14:12

Cameron Lowell Palmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!