My app presents an emoji keyboard like Apple's where the emoji are displayed by-category. I render this using a collection view where the categories are sections. If an emoji has been inserted recently, it should appear in the "Frequently Used" category as well as whatever category it's normally in.
This is a problem for me trying to convert my collection view to use a UICollectionViewDiffableDataSource
, because NSDiffableDataSourceSnapshot
requires that items are unique. If I do something like
let snapshot = NSDiffableDataSourceSnapshot<Section, Emoji>()
snapshot.appendItems([thumbsUpEmoji], toSection: .frequents)
snapshot.appendItems([thumbsUpEmoji], toSection: .smileys)
dataSource.apply(snapshot)
I get warnings like
inserted identifier(s) already present; existing items will be moved into place for this current insertion. Please note this will impact performance if items are not unique when inserted.
And the emoji only shows up in one section, not both. How can I insert the item into multiple sections?