When I worked on the challenges I noticed that editing also worked all the time without updating the ItemStore. So just overriding this tableView function was enough. I commented out the line moving items in the itemStore.
override func tableView(_ tableView: UITableView,
moveRowAt sourceIndexPath: IndexPath,
to destinationIndexPath: IndexPath) {
// Update the model
//itemStore.moveItem(from: sourceIndexPath.row, to: destinationIndexPath.row)
}
What is missing, is the response from the Model to the Controller and updating the view. To update the table needs to be reloaded. So this now works only when the item in the itemStore was moved.
override func tableView(_ tableView: UITableView,
moveRowAt sourceIndexPath: IndexPath,
to destinationIndexPath: IndexPath) {
// Update the model
itemStore.moveItem(from: sourceIndexPath.row, to: destinationIndexPath.row)
self.tableView.reloadData()
}