In this section, we'll implement the functionality for deleting notes.

We'll use the built-in functionality of UITableView for deleting objects. It's super easy! (Really)

In ListNotesTableViewController, add the following method with your other table view data source methods:

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        notes.remove(at: indexPath.row)

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.


If you have feedback on this tutorial or find any mistakes, please open issues on the GitHub Repository or comment below.

Summer academy

An iOS Development Summer Course

Design, code and launch your own app. Locations in San Francisco and Asia

Find your location

Product College

A computer science college

Graduate into a successful career as a founder or software engineer.

Learn more

Cookies on Make School's website

We have placed cookies on your device to ensure that we give you the best experience on our website.

This site uses cookies to deliver our services. By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Your use of Make School’s Products and Services is subject to these policies and terms.

Please note that Make School no longer supports Internet Explorer

We recommend upgrading to a modern web browser. Learn more