Skip to content

Instantly share code, notes, and snippets.

@nurtugan
Last active July 17, 2024 20:28
Show Gist options
  • Save nurtugan/18cacdbfdc5aa69a3eada20282fe57aa to your computer and use it in GitHub Desktop.
Save nurtugan/18cacdbfdc5aa69a3eada20282fe57aa to your computer and use it in GitHub Desktop.
Example of Deleting Item from Diffable Data Source
@objc
private func handleGet(_ sender: UIButton) {
var superview = sender.superview
while superview != nil {
if let cell = superview as? UICollectionViewCell {
guard let indexPath = collectionView.indexPath(for: cell),
let objectIClickedOnto = diffableDataSource.itemIdentifier(for: indexPath) else { return }
var snapshot = diffableDataSource.snapshot()
snapshot.deleteItems([objectIClickedOnto])
diffableDataSource.apply(snapshot)
break
}
superview = superview?.superview
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment