udacity / ios-nd-networking

Resources for Udacity's iOS Networking with Swift course.
MIT License
173 stars 89 forks source link

"Swipe to delete" functionality on watchlist/favorites list #11

Open OwenLaRosa opened 5 years ago

OwenLaRosa commented 5 years ago

Many apps using tables will allow you to manage the list directly from the table view. As a simple new feature, we can do this for the watchlist and favorites list.

To get the "swipe to "delete" functionality, you'll want to implement some methods on your watchlist or favorites view controllers.

tableView(_:canEditRowAt:): https://developer.apple.com/documentation/uikit/uitableviewdatasource/1614900-tableview tableView(_:commit:forRowAt:): https://developer.apple.com/documentation/uikit/uitableviewdatasource/1614871-tableview

In tableView(_:commit:forRowAt:), once you know the movie that's been deleted, you can simply remove it from the watchlist/favorites list using the same methods you used in MovieDetailViewController, and don't forget to update the lists in MovieModel accordingly.