I created a struct for UICollectionViewDiffableDataSource
struct Section: Hashable {
let name: String
let items: [Int]
}
And created snapshot with this structure
func updateData(for data: [Section]) {
var snapshot = NSDiffableDataSourceSnapshot<Section, Int>()
snapshot.appendSections(data)
for section in data {
snapshot.appendItems(section.items, toSection: section.name)
}
dataSource.apply(snapshot, animatingDifferences: false)
}
And here how I setup initial Data
updateData(for: [Section(name: "T", items: [1, 2]), Section(name: "J", items: [3, 4, 5]))
And if I trying add more item with this method:
updateData(for: [Section(name: "T", items: [1, 2]), Section(name: "J", items: [3, 4, 5 ,6])])
All Section "J" re-created Why this happened?
Here the example where when cell after 1 second of loading - change color to green And here we can see, what second section - re-created