app-architecture icon indicating copy to clipboard operation
app-architecture copied to clipboard

Fix typo preventing `UITableView` animations

Open dohyeondk opened this issue 6 years ago • 2 comments

In the switch below, deleteRows() or insertRows was not reached because of this typo.

switch (changeReason, newValue, oldValue) {
case let (Item.removed, _, (oldIndex as Int)?):
	tableView.deleteRows(at: [IndexPath(row: oldIndex, section: 0)], with: .automatic)
case let (Item.added, (newIndex as Int)?, _):
	tableView.insertRows(at: [IndexPath(row: newIndex, section: 0)], with: .automatic)
case let (Item.renamed, (newIndex as Int)?, (oldIndex as Int)?):
	tableView.moveRow(at: IndexPath(row: oldIndex, section: 0), to: IndexPath(row: newIndex, section: 0))
	tableView.reloadRows(at: [IndexPath(row: newIndex, section: 0)], with: .automatic)
default:
	tableView.reloadData()
}

dohyeondk avatar Apr 29 '19 16:04 dohyeondk

@chriseidhof can you review this?

dohyeondk avatar Apr 29 '19 16:04 dohyeondk

This typo is also detected by the unit tests in the MVC project - testChangeNotificationHandling fails if you run the tests out of the box - this change fixes the test.

ralfebert avatar Sep 09 '19 11:09 ralfebert