 
         let doc = database.createDocument()
         try! doc.putProperties(properties)
-        
-        textField.text = ""
+    }
+
+    func sendEditedMessage(doc: CBLDocument, message: String) {
+        if var newProps = doc.properties as? [String: AnyObject] {
+            newProps["message"] = message
+            try! doc.putProperties(newProps)
+
+            editingMessage = nil
+        }
     }
 
     func numberOfSectionsInTableView(tableView: UITableView) -> Int {

            return
        }

        let app = UIApplication.sharedApplication().delegate as! AppDelegate

        let message = text!

        let properties = [
            "type": "message",


                cell.textLabel!.text = values[1]
                cell.detailTextLabel!.text = values[0]

                cell.accessoryType = row.documentID == editingMessage?.documentID ? .Checkmark : .None
        }

        return cell
    }

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        if let row = liveQuery?.rows?.rowAtIndex(UInt(indexPath.row)) {
            editingMessage = row.document
            tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
        }
    }

}
