I have a data source like so
fileprivate func makeRecordsDataSource() -> RecordsDataSource {
let dataSource = RecordsDataSource(
collectionView: recordsCollectionView,
cellProvider: { (collectionView, indexPath, recordItem) ->
UICollectionViewCell? in
switch recordItem.type {
case .Rep:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: RepRecordCell.identifier, for: indexPath) as? RepRecordCell
cell!.configure(with: recordItem)
return cell
case .Image:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ImageRecordCell.identifier, for: indexPath) as? ImageRecordCell
cell!.configure(with: recordItem)
return cell
case .Video:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: VideoRecordCell.identifier, for: indexPath) as? VideoRecordCell
cell!.configure(with: recordItem)
return cell
case .Text:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TextRecordCell.identifier, for: indexPath) as? TextRecordCell
cell!.configure(with: recordItem)
return cell
}
})
return dataSource
}
In my view controller I have
private lazy var recordsDataSource = makeRecordsDataSource()
Then a function to apply a snapshot to my data source....
func applyRecordsSnapshot(days:[YearMonthDay]) {
var snapshot = RecordsDataSourceSnapshot()
snapshot.appendSections(days)
var i = 0
for ymd in days {
sectionMap[ymd] = i
snapshot.appendItems(ymd.recordItems,toSection: ymd)
i += 1
}
recordsDataSource.apply(snapshot, animatingDifferences: false)
}
in the debugger, when I look at the snapshot.numberOfItems, I see 4, so there are 4 sections... But for some reason the closure cellProvider never gets called when I put breakpoints inside of it. Wouldn't it get called once for each cell in the snapshot?