title: How to refresh UITableView with reloadData() on ViewDidAppear?
body: <p>I would like to reload the data in my UITableView on ViewDidAppear and populate the table with the new data from a NSUserDefaults. I know everything works with the new information populating the table, because when I turn the emulator off and on again, the new data is there. But I want it to refresh with the new data everytime I display the view. It is a reminders app.</p>
  
  <p>Here is my viewcontroller:</p>
  
  <pre><code>class FirstViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
  
      @IBOutlet var reminderTableView: UITableView!
  
      var remindersArray = NSUserDefaults.standardUserDefaults().objectForKey("remindersArray")! as AnyObject as [String]
  
      let textCellIdentifier = "reminderText"
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          reminderTableView.delegate = self
          reminderTableView.dataSource = self
      }
  
      override func viewDidAppear(animated: Bool) {
          dispatch_async(dispatch_get_main_queue()) {
              self.reminderTableView.reloadData()
          }
      }
  
      func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
          return 1
      }
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return remindersArray.count
      }
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as UITableViewCell
  
          let row = indexPath.row
          cell.textLabel?.text = remindersArray[row]
  
          return cell
      }
  }
  </code></pre>
  
  <p>I have no idea why the function in viewWillAppear is not reloading the data in the table. Any help would be much appreciated. I have tried other solutions on stackoverflow, but none of those work for me unfortunately.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is the second view controller which updates the remindersArray:</p>
  
  <pre><code>import UIKit
  
  class SecondViewController: UIViewController, UITextFieldDelegate {
  
      @IBOutlet var reminderText: UITextField!
  
      @IBAction func addReminder(sender: AnyObject) {
  
          let newReminderText = reminderText.text
  
          var nsRemindersArray = NSUserDefaults.standardUserDefaults().objectForKey("remindersArray")! as NSArray
  
          var remindersArray = nsRemindersArray as AnyObject as [String]
  
          remindersArray.append(newReminderText)
          NSUserDefaults.standardUserDefaults().setObject(remindersArray, forKey: "remindersArray")
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          self.reminderText.delegate = self
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }   
  
  }
  </code></pre>