I’ve a bizarre crash that has begun to happen that I’m unable to copy and principally occurs on the iPad tenth technology.
The crash happens when making use of a snapshot for a UICollectionViewDiffableDataSource. The content material fashions for the datasource are proven beneath and so they conform to Hashable.
I added a customized Hashable conformance in an try to repair the crash I get nevertheless it has not helped. Beforehand I simply used computerized conformance.
struct FormationContent: Hashable {
let block: Block
func hash(into hasher: inout Hasher) {
hasher.mix(block)
}
enum Block: Hashable {
case formation(FormationCellViewModel)
case add(isSelected: Bool)
func hash(into hasher: inout Hasher) {
swap self {
case .formation(let viewModel):
hasher.mix("formation")
hasher.mix(viewModel.id)
case .add(let isSelected):
hasher.mix("add")
hasher.mix(isSelected)
}
}
}
struct FormationCellViewModel: Hashable {
let id: UUID
let title: String
let isSelected: Bool
}
}
Beneath are the crash logs that do not seem to point out any duplication. Oddly the add part doesn’t seem however I assume the crash is going on earlier than the datasource makes an attempt to show that within the subsequent part:
Deadly: provided merchandise identifiers usually are not distinctive.
Duplicate identifiers:
{( footballformation.FormationContent(block: footballformation.FormationContent.Block.formation(footballformation.FormationContent.FormationCellViewModel(id: 65BF74DC-FC44-4E2E-8984-DD036543B0AD, title: "5-3-2", isSelected: false))),
footballformation.FormationContent(block: footballformation.FormationContent.Block.formation(footballformation.FormationContent.FormationCellViewModel(id: 2397B8DE-DD7C-4CED-B78D-5BDB30F0CB15, title: "4-5-1", isSelected: false))),
footballformation.FormationContent(block: footballformation.FormationContent.Block.formation(footballformation.FormationContent.FormationCellViewModel(id: F0CBB71C-B39B-4674-B950-F4CFF0FF8E72, title: "4-4-2", isSelected: false))),
footballformation.FormationContent(block: footballformation.FormationContent.Block.formation(footballformation.FormationContent.FormationCellViewModel(id: 71609229-BCC8-457F-977F-618335BC9E0B, title: "4-3-3", isSelected: false))),
footballformation.FormationContent(block: footballformation.FormationContent.Block.formation(footballformation.FormationContent.FormationCellViewModel(id: 5FA5DBE3-87A2-4CE4-9D19-2588CFE5DC28, title: "4-3-2-1", isSelected: false))),
footballformation.FormationContent(block: footballformation.FormationContent.Block.formation(footballformation.FormationContent.FormationCellViewModel(id: 631FD123-F4D9-43A2-BFA1-64F6A739B9C3, title: "3-5-2", isSelected: false))) )}
The FormationContent mannequin is for 2 sections which are dealt with with the completely different blocks. The formation id comes from a CoreData mannequin and is exclusive.
That is how I apply my snapshot:
non-public func applyFormationSnapshot(_ formationsContent: [FormationLayout.Section : [FormationContent]]) {
var snapshot = NSDiffableDataSourceSnapshot()
snapshot.appendSections([.main, .add])
if let formations = formationsContent[.main] {
snapshot.appendItems(formations, toSection: .essential)
}
if let addFormation = formationsContent[.add] {
snapshot.appendItems(addFormation, toSection: .add)
}
formationsDataSource.apply(snapshot, animatingDifferences: true)
}
Is there something apparent that I’m doing improper?
I plan so as to add some logging of the formation content material fashions to assist get a greater understanding of the difficulty through Firebase.
Thanks