In the code above, we override the table view data source method tableView(_:commit:forRowAt:) to implement the table view's built-in slide-to-delete functionality. Within the tableView(_:commit:forRowAt:) method, we check for the delete editing mode and delete the note at the corresponding index path.
That was easy!
Running the App
We've just finished implementing the functionality for deleting notes. Let's create a few notes and try deleting them to make sure everything works.
Build and run the app. Create a few new notes and try deleting them.
In the next section, we'll introduce Core Data and learn how to persist our note data between app launches.