For the last Challenge of this unit, we are going to use a delegate method from DataSource, it is invoked at time when the UITableView is going to move a row before that the method tableView(_ tableView: UITableView, moveRowAt…) had been called.
override func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath {
if (proposedDestinationIndexPath.row >= itemStore.allItems.count){
return sourceIndexPath
}
return proposedDestinationIndexPath
}
Now the challenge it’s done.
Note: You need implement my Silver Challenge first.