title: How to change the text attribute of a UILabel in Swift?
body: <p>I've set up a UILabel programmatically and I'm attempting to change the text attribute via a function I call later on in the ViewController however when that function is called the questionLabel.text stays the default value "Welcome".  </p>
  
  <p>Essentially what I'm trying to accomplish is:</p>
  
  <pre><code>  func changeLabelText() {
              questionLabel.text = "New label text"
              print(questionLabel.text!)
          }
          changeLabelText()
  
          // prints "New label text"
  
  </code></pre>
  
  <p>however what I'm actually getting is:</p>
  
  <pre><code>   func changeLabelText() {
              questionLabel.text = "New label text"
              print(questionLabel.text!)
          }
          changeLabelText()
  
          // prints "Welcome"
  </code></pre>
  
  <p>This is how my label is setup:</p>
  
  <pre><code>class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate {
  
      @IBOutlet var cameraView: UIView!
  
          var questionLabel: UILabel {
  
              let label = UILabel()
              label.lineBreakMode = .byWordWrapping
              label.backgroundColor = .white
              label.textColor = .black
              label.text = "Welcome"
              label.textAlignment = .center
              label.frame = CGRect(x: 65, y: 100, width: 300, height: 65)
  
              return label
  
          } 
  </code></pre>
  
  <p>Any suggestions?  Greatly appreciated!</p>