Realm data not showing in table view
<p>I am relatively new to iOS trying to develop a simple note app using Realm. I have a few view controllers.</p>

<p><strong>To Create a new note:</strong></p>

<pre><code>//
//  ViewController.swift
//  Note It
//
//  Created by James Parsons on 2/19/16.
//  Copyright © 2016 James Parsons. All rights reserved.
//

import UIKit
import RealmSwift
import Realm

class NewNoteViewController: UIViewController {
    // MARK: - Properties
    var save: Bool?
    var realm: Realm?

    // MARK: - Outlets
    @IBOutlet weak var txtView: UITextView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Initialize realm.
        realm = try! Realm()

        // Set up insets.
        txtView.contentInset = UIEdgeInsetsMake(-50, 10, 0, 0)

        // Do we have any data from the last time?
        let data: String? = NSUserDefaults.standardUserDefaults().objectForKey("lastNoteData") as? String

        if (data != nil) {
            txtView.text = data
        }
    }

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

    override func viewWillDisappear(animated: Bool) {
        // Do we want to save the data?
        if save! {
            if txtView.hasText() {
                // Save the current note data
                let noteData = txtView.text
                NSUserDefaults.standardUserDefaults().setValue(noteData, forKey: "lastNoteData")
            }
        } else {
            // No need to save note data. Clear the setting.
            NSUserDefaults.standardUserDefaults().setValue(nil, forKey: "lastNoteData")
        }

    }

    // MARK: - Actions
    @IBAction func btnCancel(sender: UIBarButtonItem) {
        // Save note content
        save = true
        self.navigationController!.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
    }

    @IBAction func btnSave(sender: UIBarButtonItem) {
        var alert: UIAlertController

        if txtView.hasText() {
            let textToSerialize = txtView.text

            alert = UIAlertController(title: "Save", message: "Enter a name for this note", preferredStyle: .Alert)

            let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
            let saveAction = UIAlertAction(title: "Save", style: .Default, handler: { (action: UIAlertAction) -&gt; Void in
                // DEBUG: See if this is firing.
                // By the way it works.
                print("Yay, it worked")

                // Don't serialize data.
                self.save = false

                // Get the note name.
                let name = alert.textFields!.first!.text!

                // Build the note.
                let noteToSave = Note(name: name, content: textToSerialize, date: NSDate())

                // Save the note into Realm.
                dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in
                    try! self.realm!.write {
                        self.realm!.add(noteToSave)
                    }
                })

                // Go back.
                self.navigationController!.presentingViewController!.dismissViewControllerAnimated(true, completion: nil)
            })

            alert.addTextFieldWithConfigurationHandler {
                (textField: UITextField) -&gt; Void in
            }

            alert.addAction(cancelAction)
            alert.addAction(saveAction)

            presentViewController(alert, animated: true, completion: nil)
        } else {
            // Notes cannot be blank.
            let alert = UIAlertController(title: "Whoops", message: "This note needs some content", preferredStyle: .Alert)

            let okAction = UIAlertAction(title: "Ok", style: .Default, handler: nil)
            alert.addAction(okAction)

            // Show the alert.
            presentViewController(alert, animated: true, completion: nil)

        }
    }
}
</code></pre>

<p><strong>The Main View:</strong></p>

<pre><code>//
//  NotesViewController.swift
//  Note It
//
//  Created by James Parsons on 2/19/16.
//  Copyright © 2016 James Parsons. All rights reserved.
//

import UIKit
import RealmSwift
import Realm

class NotesViewController: UITableViewController {
    // MARK: - Properties
    var notes: Results&lt;Note&gt;?
    var realm: Realm?

    // MARK: ViewController methods.
    override func viewDidLoad() {
        super.viewDidLoad()

        // Refresh the table.
        dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in
            self.tableView.reloadData()
        })

        // Set up our Realm.
        realm = try! Realm()

        // Get all the notes.
        notes = realm!.objects(Note)
    }

    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 {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
        // Return number of objects.
        return realm!.objects(Note).count
    }

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

        // Set up the cell with our data
        if let note = notes?[indexPath.row] {
            cell.textLabel!.text = note.name
            cell.detailTextLabel!.text = dateToString(note.dateCreated)
        }

        return cell
    }


    /*
    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -&gt; Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -&gt; Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    // MARK: - Functions
    func dateToString(date: NSDate) -&gt; String {
        let formatter = NSDateFormatter()
        formatter.dateStyle = .ShortStyle

        return formatter.stringFromDate(date)

    }

}
</code></pre>

<p><strong>And the model</strong></p>

<pre><code>//
//  Note.swift
//  Note It
//
//  Created by James Parsons on 2/19/16.
//  Copyright © 2016 James Parsons. All rights reserved.
//

import Foundation
import RealmSwift

// Realm model for notes.
class Note: Object {
    // MARK: - Properties
    dynamic var name = ""
    dynamic var content = ""
    dynamic var dateCreated = NSDate()

    // MARK: - Intializers
    required init() {
        super.init()
    }

    required init(name: String, content: String, date: NSDate) {
        self.name = name
        self.content = content
        self.dateCreated = date

        super.init()
    }

}
</code></pre>

<p>I know the handler on the save action fires, but no data ever shows in the table. What am I doing wrong?</p>