By implementing tableView(_:commitEditingStyle:forRowAtIndexPath:), we enable the 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.
Because we modified the notes array, we must tell the table view to update itself with reloadData().
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.