Swift 2.2 - NSUserDefaults not working and adding to list iOS
<p>When I use NSUserDefaults, it is not working and reloading the data on the tableView. I have a page to add an item, but it shows the item added, and when I open it again, it is not saving. here is my full code.</p>

<pre><code>import UIKit

var noteTitles = [String]()
var text = [String]()

class TableViewController: UITableViewController {

  override func viewDidAppear(animated: Bool) {
    tableView.reloadData()
  }

  override func viewDidLoad() {
    super.viewDidLoad()

    if NSUserDefaults.standardUserDefaults().objectForKey("note") != nil {

      noteTitles = NSUserDefaults.standardUserDefaults().objectForKey("note") as! [String]

    }

    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem()
  }

  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }

  // MARK: - Table view data source

  override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
    // #warning Incomplete implementation, return the number of sections
    return 1
  }

  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
    // #warning Incomplete implementation, return the number of rows
    return noteTitles.count
  }


  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell

    cell.textLabel?.text = noteTitles[indexPath.row]

    // Configure the cell...

    return cell
  }
</code></pre>

<p>I don't know what is going wrong, and Xcode does not show any errors or warnings. What did I do wrong, and how would I fix it? </p>