RxDataSources
RxDataSources copied to clipboard
conform to 'RxCollectionViewDataSourceType'
I am a stranger to RxDataSources,when I set the datasource to UICollectionView, got the error:
Instance method 'items(dataSource:)' requires that 'CollectionViewSectionedDataSource<NoticeList>' conform to 'RxCollectionViewDataSourceType'
code:
let dataSource = RxCollectionViewSectionedReloadDataSource<NoticeList> { (dataSource, collectionView, indexPath, model) -> UICollectionViewCell in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell",
for: indexPath) as! ListCollectionViewCell
cell.titleLabel.text = model.title
cell.numberLabel.text = String(indexPath.row)
return cell
}
...
NoticeListViewModel().data.asDriver(onErrorJustReturn: []).drive(collectionView.rx.items(dataSource: dataSource)).disposed(by:disposeBag)
me too
Same here...what is even weirder is that it works in one project and fails in another project
error view but successed controller
same, any workaround?
I was having this issue, but was fixed by instead of having a DataSource of type Item you need to pass Section
typealias DataSource = RxTableViewSectionedReloadDataSource<MyCustomSection>
me too :(
I think your property's type or return type of function in viewModel is not Section type.
still getting the same error.. i'm confused
same error for RxTableViewSectionedAnimatedDataSource:
Instance method 'items(dataSource:)' requires that 'TableViewSectionedDataSource<LiveGenreSectionModel>' (aka 'TableViewSectionedDataSource<AnimatableSectionModel<LiveGenreSectionHeader, LiveGenreSectionItem>>') conform to 'RxTableViewDataSourceType'
maybe the the type of data is different from the type you set in RxTableViewSectionedReloadDataSource.
here's an example:
// this is wrong because it's Observable<[String]>, not Observable<[MyCustomSection]>.
// if you write like this, you will get the error tip.
let data = Observable<[String]>.just(["first element", "second element", "third element"])
// Observable<[MyCustomSection]> is what it wants: array of CustomSection
let section = MyCustomSection(header: "1", items:["first element", "second element", "third element"])
let data = Observable<[MyCustomSection]>.just([section])
let dataSource = RxTableViewSectionedReloadDataSource<MyCustomSection>(
configureCell: { ds, tv, ip, item in
let cell = tv.dequeueReusableCell(withIdentifier: "cell", for: ip)
cell.textLabel?.text = "Item \(item)"
return cell
}
)
data.bind(to: tableView.rx.items(dataSource: dataSource)).disposed(by: disposeBag)