Reputation: 80
Hey I'm trying to get an UICollectionView, hosted by an UICollectionViewController working with RxCocoa and RxDataSources.
Everything works fine when I use an UIViewController, with an embedded UICollectionView.
But when I try to connect via the same logic:
self.vm.sections
.bind(to: self.collectionView!.rx.items(dataSource: self.vm.data))
.disposed(by: self.bag)
with an UICollectionView inside an UICollectionViewController, Xcode crashes completely.
Is there something I'm missing about RxDataSources, that you cannot use them with UICollectionViewController?
Upvotes: 3
Views: 1015
Reputation: 1093
If you inherit from UITableViewController you must call tableView.datasource = nil
anytime you are doing a whole table reload or refresh action
Upvotes: 2
Reputation: 1487
Though I have no idea about why Xcode crashes, it seems to be caused by RxCocoa's assertion checking.
The data source of UICollectionViewController
's collectionView
is set by default.
How about setting it to nil
before binding with observable?
self.collectionView!.dataSource = nil
self.vm.sections
.bind(to: self.collectionView!.rx.items(dataSource: self.vm.data))
.disposed(by: self.bag)
Upvotes: 5
Reputation: 2680
You should not use UICollectionViewController
with RxDataSource
When use RxDatasource you must use UIViewController
and create a UITableView or UICollectionView inside it.
Upvotes: -1