By implementing tableView(_:commitEditingStyle:forRowAt indexPath:), we enable the table view to have additional editing modes, one of which is that the cells display the delete option when a user swipes right. The other mode is an insert mode, but that won't appear without additional configuration.
We check to see if the editingStyle is the .delete one - there's also an .insert one. We wouldn't want to accidentally delete a user's notes when they intended to insert a new one!
We are removing the appropriate note from the notes array, using the row property of the passed in indexPath.
And that's all we have to do to delete a note! =]
Running the App!
You should now be able to add, modify, and delete notes!
In the next tutorial we will start working on persisting data between app launches!
On this page, you should have:
Implemented tableView(_:commitEditingStyle:forRowAtIndexPath:) in the ListNotesTableViewController so that users can delete notes by swiping right on them.