<div dir="ltr">Similarly, a weak reference cannot be non-optional. I would be uncomfortable with an attribute changing that behavior. Having a non-optional field become nil or crash behind the scenes discards the safety of the Swift type system.<div><br></div><div>There are legitimate situations where a class might have unused outlets as well, where you would want an optional (`?`) type; for example, you could have an iPad nib that has additional views that aren't present in an iPhone nib, but both share the same view controller. In that case, you would want to have some of those outlets still be optional. (Your pitch may not prevent that behavior, but it's worth pointing out as a use case.)</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, May 18, 2016 at 6:42 AM Vladimir.S via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Correct me if I'm wrong, but `weak` reference can not be `let` just by<br>
definition: at some point in time such reference *can* become nil.<br>
<br>
On 18.05.2016 16:22, Daniel Steinberg via swift-evolution wrote:<br>
> I would like to propose we modify the meaning of @IBOutlet in light of the accepted proposal SE-0054 Abolish ImplicitlyUnwrappedOptional type. I think this fits in with the current Swift 3 goals.<br>
><br>
> Currently we use “var” and “!” when we declare an outlet like this:<br>
><br>
> @IBOutlet weak var myLabel: UILabel!<br>
><br>
> The “!” in the declaration allows us to use the outlet like this without unwrapping it<br>
><br>
> myLabel.text = “Hello"<br>
><br>
> We use “var” and “UILabel!" because myLabel starts its life out as nil and does not have a value until the connection is made. i.e. myLabel must be an optional if it accepts nil and the type is UILabel! instead of UILabel? so that we don’t have to unwrap it each time we use it.<br>
><br>
> If we break the connection to the UILabel instance we crash at runtime for attempting to unwrap nil.<br>
><br>
> Given this, I propose that we be able to write<br>
><br>
> @IBOutlet weak let myLabel: UILabel<br>
><br>
> In this case @IBOutlet has a meaning somewhat similar to lazy - it’s not that myLabel doesn’t exist until we first call it, but @IBOutlet indicates that myLabel should exist before we call it.<br>
><br>
> If the connection isn’t made and myLabel doesn’t exist, we should crash as we do now. If the connection is not made in the nib or storyboard, this will crash at development time.<br>
><br>
> This removes a case in which we use var - not because we want to change the value of a property but because of a detail in the tooling.<br>
><br>
> This change also removes a case in which we use an Optional again for a detail in lifecycle and tooling.<br>
><br>
> Best,<br>
><br>
> Daniel<br>
> _______________________________________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
><br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>