title: UITableView: Load data from array after viewDidLoad()
body: <p>I'm trying to load the items of an array into a UITableView in a Swift iOS App.</p>
  
  <p><strong>ViewController.swift</strong></p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      let website = MyWebsite()
      let authenticated = ViewAuthenticated()
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      @IBAction func getData(_ sender: Any) {
          var arrayTEST = self.website.getArray() //["red", "green", "blue"]
          self.authenticated.data = arrayTEST //["red", "green", "blue"]
          let viewAuth = self.storyboard?.instantiateViewController(withIdentifier: "ViewAuthenticated") as! ViewAuthenticated
          self.present(viewAuth, animated: true)
      }
  
  }
  </code></pre>
  
  <p><strong>ViewAuthenticated.swift</strong></p>
  
  <pre><code>import UIKit
  
  class ViewAuthenticated: UIViewController, UITableViewDataSource {
  
      @IBOutlet weak var tableView: UITableView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          tableView.dataSource = self
      }
  
      func numberOfSections(in tableView: UITableView) -&gt; Int {
          return 1
      }
  
      public var data: [String] = ["123", "456", "789"]
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return data.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "cellReuseIdentifier")!
          let text = data[indexPath.row]
          cell.textLabel?.text = text
          return cell
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
  
  }
  </code></pre>
  
  <p>What I would like to do is creating a UITableView containing the items sent by ViewController.
  I think the problem is that in ViewAuthenticated the UITableView is created before ViewController sends his new array (["red", "green", "blue"]).
  How can I solve this?</p>