Last active
July 17, 2024 20:28
-
-
Save nurtugan/18cacdbfdc5aa69a3eada20282fe57aa to your computer and use it in GitHub Desktop.
Example of Deleting Item from Diffable Data Source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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