RxDataSources icon indicating copy to clipboard operation
RxDataSources copied to clipboard

Fatal error: Duplicate item ...

Open nickfl opened this issue 5 years ago • 1 comments

Log shows first:

Item <HD_Rx.TrackItemPresentable: 0x6000034ab980> has already been indexed at (0, 33)
Fatal error: Duplicate item <HD_Rx.TrackItemPresentable: 0x6000034ab980>: file
..../Pods/RxDataSources/Sources/RxDataSources/DataSources.swift, line 32

Where TrackItemPresentable is part of TrackSection = AnimatableSectionModel<String, TrackItemPresentable>

Binding is done standard way:

    viewModel.sectionedItems
      .bind(to: tableView.rx.items(dataSource: dataSource))
      .disposed(by: self.rx.disposeBag)

where var sectionedItems: Observable<[TrackSection]>

And app crashes on the next update of sectionedItems.

nickfl avatar Jan 22 '20 21:01 nickfl

OK, I kinda fixed it. The problem was in dataSource: .bind(to: tableView.rx.items(dataSource: dataSource))

as looks like dataSource keeps all previous data. Maybe there is a method to flush it, but I couldn't find it.

So, I got rid of it and used a more direct binding on the go:

 .bind(to: tableView.rx.items(cellIdentifier: ResultTableViewCell.reuseId)) { row, model, cell in
     (cell as ResultTableViewCell).configureCell(track: model)
 }

nickfl avatar Jan 22 '20 22:01 nickfl