Here is my code snippet:
class ProductCategoryCell: UITableViewCell {
@IBOutlet weak var collectionViewProducts: UICollectionView!
// other stuff...
func setProducts() {
let productsObservable = Observable.just([
Product(name: "test", price: 10.0),
Product(name: "test", price: 10.0),
Product(name: "test", price: 10.0)
])
productsObservable.bindTo(collectionViewProducts.rx.items(cellIdentifier: "ProductCell", cellType: ProductCell.self)) {
(row, element, cell) in
cell.setProduct(element)
}.disposed(by: disposeBag)
}
}
It is giving me a build error:
No 'items' candidates produce the expected contextual result type '(Observable<[Product]>) -> (_) -> _'
In my view controller, I am populating table view with a similar code:
let productsObservable = Observable.just(testProducts)
productsObservable.bindTo(tableViewProducts.rx.items(cellIdentifier: "ProductCategoryCell", cellType: ProductCategoryCell.self)) { (row, element, cell) in
cell.setCategory(category: element)
}.disposed(by: disposeBag)
This code works normally for. What am I doing wrong?