Collection Views

Sep 10 2020 · Swift 5.3, iOS 14, Xcode 12

Part 3: Build the Library

28. Deleting Courses Using Snapshots

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 27. Adding Courses to a Queue Next episode: 29. Adding Item Badges

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 28. Deleting Courses Using Snapshots

If you're interested in working on a more robust deletion implementation, so that tutorials stay deleted from the Queue tab, check out this code you can add to the deleteSelectedItems method that will update the DataSource:

@IBAction func deleteSelectedItems() {
guard let selectedIndexPaths = collectionView.indexPathsForSelectedItems else { return }
let tutorials = selectedIndexPaths.compactMap { dataSource.itemIdentifier(for: $0) }

// Get all of the tutorials in the data source that are currently queued
let queuedTutorials = DataSource.shared.tutorials.flatMap { $0.queuedTutorials }
// Find the queued tutorials that will be deleted from the collection view
let tutorialsToUnqueue = Set(tutorials).intersection(queuedTutorials)
// Set the `isQueued` property to false for each matching tutorial
tutorialsToUnqueue.forEach { $0.isQueued = false }
...

Update Note: This course was originally recorded in November, 2019 using Xcode 11 & iOS 13. The course has been reviewed, and all materials updated to Xcode 12 & iOS 14 as of September, 2020.