so i started learning about rxCocoa, and tried to implement it into a collectionview, I see no problem with tableview and it supposed to do the same with collectionView But somehow this error showed up.
So how exactly to use rx bind ? and why the error showed up
Thank you
my View Controller
final class ViewController: UIViewController {
var presenter:HomePresenter?
private lazy var collectionView:UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
layout.minimumLineSpacing = 1
layout.minimumInteritemSpacing = 1
layout.itemSize = CGSize(width: (view.bounds.width/2)-2, height: 370)
let collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
collectionView.backgroundColor = .white
return collectionView
}()
override func viewDidLoad() {
super.viewDidLoad()
// THIS IS WHERE THE ERROR STARTS
presenter?.getProductList().bind(to: collectionView.rx.items(cellIdentifier: ProductCollectionViewCell.identifier, cellType: ProductCollectionViewCell.self){a,b,c in
}).dispose(by:disposeBag)
}
}
my presenter
func getProductList() -> Observable<[ProductEntity]> {
return self.interactor.getProductList()
}
You have your parens in the wrong place...
presenter?
.getProductList()
.bind(to: collectionView.rx.items(cellIdentifier: ProductCollectionViewCell.identifier, cellType: ProductCollectionViewCell.self)) { a, b, c in // two close parens here
} // no close paren here
.disposed(by: disposeBag)