I have an UITableView and a countries
variable whose signature is like:
let countryArray = ["Bangladesh", "India", "Pakistan", "Nepal", "Bhutan", "China", "Malaysia", "Myanmar", "Sri Lanka", "Saudi Arabia"]
When I'm trying to bind this array of countries in a UITableView, Its showing the error Generic parameter 'Self' could not be inferred
.
Here is the snippet that I am doing:
let countries = Observable.just(countryArray)
countries.bindTo(self.tableView.rx.items(cellIdentifier: "myCell",
cellType: MyCell.self)) {
row, country, cell in
// configuring cell
}
.addDisposableTo(disposeBag)
I would suggest you to use the latest version of RxSwift. What you're using right now is deprecated. Your error may be related to it.
There are two ways to do what you're doing:
To provide the cell type in the
items(cellIdentifier:cellType:)
, that's basically what you are doing:To provide the cell factory closure, in other words dequeue the cell in the closure and return it:
Both have pros and cons. The second one has a reference to the
tableView
which sometimes can be very handy.