         
         self.presentViewController(alert, animated: true, completion: nil)
 
-        tableData.removeAtIndex(indexPath.row)
+        let fetchResults = self.fetch()
+        
+        if fetchResults.count > 0 {
+            let itemToDelete = fetchResults[indexPath.row]
+            
+            // Delete it from the managedObjectContext
+            managedObjectContext?.deleteObject(itemToDelete)
+            self.save()
+        }
+        
+        //tableData.removeAtIndex(indexPath.row)
         self.toDoList?.reloadData()
     }
 }

        // Register the UITableViewCell class with the tableView
        self.toDoList?.registerClass(UITableViewCell.self, forCellReuseIdentifier: self.cellIdentifier)
        
        let newItem = NSEntityDescription.insertNewObjectForEntityForName("ToDoItem", inManagedObjectContext: self.managedObjectContext!) as ToDoItem
        
        newItem.itemName = "First thing"
        //tableData.append(newItem)
    }


        self.toDoText.endEditing(true)
        
        //tableData.append(newItem)
        self.save()
        
        self.toDoList?.reloadData()
    }
