3
votes

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/

1
I am always creating a weak references for an IBOutlet.Hemang

1 Answers

2
votes

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.