I am trying RxDataSources https://github.com/RxSwiftCommunity/RxDataSources for simple TableView
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
let items = [
CustomItem(id: 12, title: "name"),
CustomItem(id: 22, title: "your age"),
CustomItem(id: 77, title: "style")
]
let data = Observable<[CustomItem]>.just(items)
data.bind(to: tableView.rx.items(cellIdentifier: "CustomCell", cellType: CustomCell)) {
index, model, cell in
cell.questionLbl.text = model
}
.disposed(by: disposeBag)
}
}
class CustomCell: UITableViewCell {
@IBOutlet weak var questionLbl: UILabel!
}
struct CustomItem: Equatable {
let id: Int
let title: String
static func == (lhs: CustomItem, rhs: CustomItem) -> Bool {
return lhs.id == rhs.id
}
}
And I got this error:
Generic parameter 'Self' could not be inferred
p.s. as you see - I added Equatable to my struct but it also not working. same time if I change array of custom object to array of Strings, everything starts to work fine.