I'm following a tutorial on Swift and I noticed that the author uses var
instead of let
when declaring an @IBOutlet
variable. So I became curious as to why I can't use let
instead since an object's properties are still mutable even if the object is constant or is this not the case?
The error Xcode shows when using let
is
@IBOutlet
attribute requires property to be mutable
but I'm confused because questionLabel
is a UILabel
object and not necessarily a property of an object. Or is the questionLabel
object a property of the current viewController?
import UIKit
class ViewController: UIViewController {
@IBOutlet let questionLabel: UILabel!
}
Thank you in advance if I'm over analyzing.