Adding the ability to edit the list of items by either deleting them or rearranging them is easy as well. All we need to do is implement few more methods to let our ItemTableViewController know that we want to delete certain rows or rearrange them and write code to update our model representing the list, which is our array of items.
First, let's implement deleting. To turn on deleting, we need to perform the following steps:
- Implement the tableView(_:canEditRowAt:) method. In this method, we need to return true and it will allow deleting of all rows and hence all Shopping List Items. Setting this to true will allow users to swipe the cell to the left to reveal the Delete button, or it can be swiped all the way to the left ...