             do {
                 try realm.write {
                     realm.delete(selectedObjects)
-                    selectedObjects = []
+                    resetData()
                 }
             } catch {
                 print("Could not perform deletion. Error \(error)")

    }
    
    private func deleteAllObjects() {
        if objects.isNonEmpty {
            do {
                try realm.write {
                    realm.delete(objects)
                    objects = []
                    filteredObjects = []
                    realmView.tableView.reloadData()
                }
            } catch {
                print("Couldn't delete all realm objects.")
            }
        }
    }
    
    private func deleteObjects() {

        realmView.tableView.allowsMultipleSelectionDuringEditing = true
        isEditMode.toggle()
        if !isEditMode {
            if selectAll { deleteAllObjects() } else { deleteObjects() }
            let result: Results<DynamicObject> = realm.dynamicObjects(schema.className)
            objects = Array(result)
            realmView.tableView.reloadData()
            
            navigationItem.leftBarButtonItem = nil
            navigationItem.rightBarButtonItem?.title = "Select"
