Last active
November 12, 2020 19:29
-
-
Save nashysolutions/ee76c9164fdca0c461e71a79f246511d to your computer and use it in GitHub Desktop.
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
func toggleSelectedStateOfItem(at indexPath: IndexPath) { | |
let item = dataSource.itemIdentifier(for: indexPath)! | |
var snapshot = dataSource.snapshot() | |
item.isSelected = !item.isSelected | |
snapshot.reloadItems([item]) | |
dataSource.apply(snapshot) | |
} | |
let cellProvider: CellProvider = { (tableView, indexPath, item) -> UITableViewCell? in | |
let cell = tableView.dequeueReusableCell( | |
withIdentifier: cellIdentifier, | |
for: indexPath) as! MenuItemTableViewCell | |
cell.accessoryType = item.isSelected ? .checkmark : .none | |
cell.textLabel?.text = item.name | |
return cell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment