Deleting a Shopping List

To delete a Shopping List is similar to adding. We need to define a new delete method on the Shopping List class. In that method, make a DELETE request to the /shopping_lists/:id endpoint where :id is the ID of our Shopping List model. We already have to delete implemented in our Table View Controller but we need to invoke this new delete method from our Table View Controller, and, on a successful DELETE request to our API server, we need to update the Table View by reloading it. To add the delete functionality, we need to follow these steps:

  1. Open the ShoppingList.swift file from our iOS project and add the following delete method to the class. In this method, we make the request by specifying the DELETE HTTP method ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.