I'm using the new NSDiffableDataSourceSnapshot and UITableViewDiffableDataSource with a UITableView. I'm having no problems building the table but I'm having problems updating a cell when the data shown in it changes. I haven't found any Apple documentation explaining how to do this. I've tried the following:
self.currentSnapshot.reloadItems([Item(identifier: identifier)])
self.dataSource.apply(self.currentSnapshot)
I get the following error in reloadItems:
Assertion failure in -[__UIDiffableDataSourceSnapshot _reloadViewUpdatesForDiffUpdate:dataSource:ignoreInvalidItems:]
I have checked that the identifier passed to the Item initializer already exists in the snapshot.
Here is my Item class:
class Item: Hashable, Equatable {
let identifier: String
var matchWrapper: MatchWrapper
init(matchWrapper: MatchWrapper) {
self.identifier = matchWrapper.identifier
self.matchWrapper = matchWrapper
}
func hash(into hasher: inout Hasher) {
hasher.combine(self.identifier)
}
static func == (lhs: ScoresViewController.Item, rhs: ScoresViewController.Item) -> Bool {
return lhs.identifier == rhs.identifier
}
}
Any suggestions?