[ad_1]
I’ve a knowledge supply like so
fileprivate func makeRecordsDataSource() -> RecordsDataSource {
let dataSource = RecordsDataSource(
collectionView: recordsCollectionView,
cellProvider: { (collectionView, indexPath, recordItem) ->
UICollectionViewCell? in
change recordItem.kind {
case .Rep:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: RepRecordCell.identifier, for: indexPath) as? RepRecordCell
cell!.configure(with: recordItem)
return cell
case .Picture:
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 .Textual content:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TextRecordCell.identifier, for: indexPath) as? TextRecordCell
cell!.configure(with: recordItem)
return cell
}
})
return dataSource
}
For my part controller I’ve
non-public lazy var recordsDataSource = makeRecordsDataSource()
Then a perform to use a snapshot to my knowledge supply….
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)
}
within the debugger, once I have a look at the snapshot.numberOfItems, I see 4, so there are 4 sections… However for some cause the closure cellProvider by no means will get known as once I put breakpoints within it. Would not it get known as as soon as for every cell within the snapshot?
[ad_2]
