When reloading a table view data with NSDiffableDataSourceSnapshot
, the table view will only reload sections that contain differences from the previous snapshot.
I have a table view that contains entries with specific dates. The entries are ordered by sections for the entry week/month/custom date range, based on what the user had chosen in the segment control.
When I have a week section and this week is the only week that exist for this month, the section will not update when the user chooses a different date range and the header will stay the same.
How can I get all section headers to be reloaded regardless of if there is a difference between this and the previous snapshot?
Here is the code for setting up the snapshot:
struct EntriesSection {
let date: Date
var entries: [Entry] = []
}
var sections: [EntriesSection]()
private func setupSnapshot() {
snapshot = NSDiffableDataSourceSnapshot<Date, Entry>()
sections.forEach {
snapshot.appendSections([$0.date])
snapshot.appendItems($0.entries, toSection: $0.date)
}
dataSource?.apply(snapshot, animatingDifferences: true)
}
Results:
Thanks in advance.