title: Adding text to a textview using a function
body: <p>I am trying to add text to a textview without using a button and I keep getting fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) when the aButton is pressed. The error brings me to the myTextView.text = "" line. The posts that I have found regarding the error thus far which is this one What does "fatal error: unexpectedly found nil while unwrapping an Optional value" mean? are great if your problem is a declared variable which you can fix by using the if let method but the answer becomes a lot more difficult when it pertains to adding text to a textview.</p>
  
  <pre><code>class ViewController: UIViewController
  {
  var textArray: [String] = []
  @IBOutlet weak var myTextView: UITextView! 
       func addText()
  {
    myTextView.text = ""
  
     for words in textArray
    {
    myTextView.textStorage.append(NSAttributedString(string: words))
    }
  }
   @IBAction func aButton(_ sender: Any)
    {
     textArray.append("a ")
     ViewController().addText()
    }
  }
  </code></pre>