27

I'm using Xcode 6.2 for iOS projects. In older versions of Xcode, when a connection was create for an IBOutlet, it was always weak storage. Now when I create connections, they are defaulted to strong. I leave it that way and don't notice any difference.

Which version of Xcode did the default change to strong and why?

4thSpace
  • 43,672
  • 97
  • 296
  • 475

2 Answers2

35

Yes, previously outlets should generally be weak but Apple has changed that. Now they recommend to use strong outlets in the WWDC 2015 session Implementing UI Designs in Interface Builder. The only reason why it might be weak is retain cycle.

Community
  • 1
  • 1
beryllium
  • 29,669
  • 15
  • 106
  • 125
  • With Xcode 8.3.1 the IBOutlets created in IB are `weak var` – neoneye Apr 18 '17 at 11:23
  • 1
    The presenter goes over strong/weak connections at about 32:30 in the presentation. That said, I highly recommend watching the whole thing as well - tons of useful information especially if you're new to iOS development :) – FateNuller Aug 01 '17 at 02:00
  • Still the same in Xcode 10.0, the IBOutlets created in IB are still weak var. – Yuchen Oct 16 '18 at 15:05
  • 4
    Xcode uses whatever _you_ chose last for weak / strong. – jacob bullock Sep 05 '19 at 15:40
14

It doesn't matter weak or strong the outlet is in most cases. You just be sure that you don't have strong reference cycles.

Subviews shouldn't have strong outlets to their superviews and view shouldn't have strong outlet to its controller, because superview already has strong reference to its subviews and controller has strong reference to its view.

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113