I have a view model that has an element that returns an observable array after calling an API.
I then find that result to a table view to display it. The problem I am having is how to call the detail view controller on the specific cell that is clicked. I bound the results with:
let queryResults = eventsViewModel.mainTableItems
queryResults
.bind(to: collectionView.rx.items) { collectionView, row, item in
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: IndexPath(row: row, section: 0)) as! EventCell
cell.heroID = "heroCellID"
cell.restaurantNameLabel.text = item.name
cell.restaurantDetailLabel.text = item.location
cell.timeLabel.text = item.date
cell.restaurantImageView.kf.setImage(with: URL(string: item.image))
return cell
}
.addDisposableTo(disposeBag)
I have no way to access the specific element in this observable array that was clicked. It says an Observable array cannot have subscript.
This is the code that says that:
vc.festival = queryResults.value[indexPath.row]
I am still new to RxSwift and I am struggling to understand this.