title: Root View Controller Swift
body: <p>I have a function in my app delegate which appends an item to an array in my a file named ViewController.swift, and then I want to reload a tableview in that same file. I attempt to do so like so:</p>
  <pre><code>let vc = ViewController()
  let navigationController = UINavigationController(rootViewController: vc)
  window!.rootViewController = navigationController
  println(vc.messages)
  
  //1        vc.messages.append(message.data.message as! String)
  //2        vc.MessageTableView?.reloadData()
  </code></pre>
  <p>The lines numbered 1,2 are where I set breakpoints. It appears to break after line numbered 2.</p>
  <p>The exact error I get is</p>
  <blockquote>
  <p>fatal error: unexpectedly found nil while unwrapping an Optional value</p>
  </blockquote>
  <p>I believe my problem is that I am setting the root view controller incorrectly.</p>
  <h1>Edit #1</h1>
  <p>Window is declared up top.</p>
  <p>If i run my code like this:</p>
  <pre><code>    let vc = ViewController()
      messages.append(message.data.message as! String)
      vc.MessageTableView?.reloadData()
      println(messages)
  </code></pre>
  <p>Then I can see that the correct data is put into the array (Which i made global for this scenario) but the table does not get updated in the View controller.</p>