Deleting an item

Deleting an Item is very similar to deleting a Shopping List where we need to make a DELETE request to the /items endpoint instead, with the ID of the item passed in the URL. Just like addition, we need to update the remove method inside the ShoppingList class so that it can make a network request to delete and invoke an onCompletion handler that we can use to update the tableView. For this, we need to make two changes. They are as follows:

  1. Inside of the ShoppingList.swift file of the iOS project, update the method signature of the remove method to take an extra parameter called the onCompletion closure function. Inside this function, make the network request to delete the item from the server. On success, remove the item ...

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.