How to reload tableview after adding new entry?
<p>I am creating a cloudkit tableview. I load the app and my tableview appears with my entries from cloud kit.</p>

<p>I then use my add method <code>insertNewObject</code> which adds the record to cloud kit but this does not show up in my tableview. It will only show up on my next run of the app.</p>

<pre><code>   func insertNewObject(sender: AnyObject) {

    let record = CKRecord(recordType: "CloudNote")
    record.setObject("New Note", forKey: "Notes")

    MyClipManager.SaveMethod(Database!, myRecord:record)
    dispatch_async(dispatch_get_main_queue()) {
        self.tableView.reloadData()
    }


    }
</code></pre>

<p>This is my add method. I am calling tableview reload as you can see but nothing is happening.</p>

<p>My tableview creation code:</p>

<pre><code>    // Tableview stuff --- Done

override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
    return 1
}
        /////// Get number of rows
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
    return objects.count
}
        //// FIll the table
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

    let object = objects[indexPath.row] 
    cell.textLabel!.text = object.objectForKey("Notes") as? String
    return cell
}

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
}
</code></pre>

<p>As requested: Method that saves to CloudDB</p>

<pre><code>   func SaveMethod(publicDatabase: CKDatabase, myRecord: CKRecord ) -&gt; CKRecord {

    publicDatabase.saveRecord(myRecord, completionHandler:
        ({returnRecord, error in
            if let err = error {
                self.notifyUser("Save Error", message:
                    err.localizedDescription)
            } else {
                dispatch_async(dispatch_get_main_queue()) {
                    self.notifyUser("Success",
                        message: "Record saved successfully")
                }


            }
        }))
 return myRecord
}
</code></pre>

<p>My viewdidload method in masterview:</p>

<pre><code>override func viewDidLoad() {
        super.viewDidLoad()
        // Database loading on runtime
        Database = container.privateCloudDatabase

        ///Build Query
        let query = CKQuery(recordType: "CloudNote", predicate: NSPredicate(format: "TRUEPREDICATE"))

        ///Perform query on DB
        Database!.performQuery(query, inZoneWithID: nil) { (records, error) -&gt; Void in
            if (error != nil) {
                NSLog("Error performing query. \(error.debugDescription)")
                return
            }

            self.objects = records!

            dispatch_async(dispatch_get_main_queue()) {
                self.tableView.reloadData()
            }

        }
</code></pre>