Why exactly doesn't this work? When the tableview reloads data, the objects move to their original position
override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
var objects = myFetchRC.fetchedObjects!
let object = myFetchRC.object(at: sourceIndexPath)
objects.remove(at: sourceIndexPath.row)
objects.insert(object, at: destinationIndexPath.row)
CoreDataStack.shared.saveContext()
tableView.reloadData()
}
EDIT: moving the reload data function to after the save context does not solve the issue, unfortunately.
Try swapping
tableView.reloadData()andCoreDataStack.shared.saveContext().Core Data only fully commits your changes when you save the managed object context, so when the tableView reloads, you are likely still getting the old ordering.