I created custom collectionViewCell to binding data from an obsersable to custom CollectionViewCell. I successfully bind data to a custom TableViewCell but I can't show the contents of data to custom collection view cell. Is there a problem with Rx binding with custom collection view data source?
It's my custom collection view cell:
class MovieItemCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var titleLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
func bind(_ viewModel: MovieItemViewModel) {
debugPrint("bind")
titleLabel.text = viewModel.title
}
}
Here's how I binding: (The following code worked completely for a tableViewCell but it does not work for collectionViewCell. By the way, the debugger do not enter to bind methods in collectionViewCell)
output.movies.drive(
topRatedMoviesCollectionView
.rx.items(cellIdentifier: MovieItemCollectionViewCell.reuseID,
cellType: MovieItemCollectionViewCell.self)) {_, viewModel, cell in
cell.bind(viewModel)
}.disposed(by: disposeBag)
The code you posted is fine and has nothing to do with the problem you are having.
If "the debugger do not enter to bind methods in collectionViewCell" then it is likely that your movies
observable never emitted any values.