I am trying to use RxSwift/RxDataSource with TableView but I am not able to assign configureCell with an existing function. Code below:
import UIKit
import RxSwift
import RxCocoa
import RxDataSources
class BaseTableViewController: UIViewController {
// datasources
let dataSource = RxTableViewSectionedReloadDataSource<TableSectionModel>()
let sections: Variable<[TableSectionModel]> = Variable<[TableSectionModel]>([])
let disposeBag: DisposeBag = DisposeBag()
// components
let tableView: UITableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
setDataSource()
}
func setupUI() {
attachViews()
}
func setDataSource() {
tableView.delegate = nil
tableView.dataSource = nil
sections.asObservable()
.bindTo(tableView.rx.items(dataSource: dataSource))
.addDisposableTo(disposeBag)
dataSource.configureCell = cell
sectionHeader()
}
func cell(ds: TableViewSectionedDataSource<TableSectionModel>, tableView: UITableView, indexPath: IndexPath, item: TableSectionModel.Item) -> UITableViewCell! {
return UITableViewCell()
}
func sectionHeader() {
}
}
Xcode throws the following error:
/Users/.../BaseTableViewController.swift:39:36: Cannot assign value of type '(TableViewSectionedDataSource, UITableView, IndexPath, TableSectionModel.Item) -> UITableViewCell!' to type '(TableViewSectionedDataSource, UITableView, IndexPath, TableSectionModel.Item) -> UITableViewCell!'
the error is thrown at line
dataSource.configureCell = cell
Do you have any idea?
Thanks