ios - 无法在 RxDataSources 中推断通用参数“Self”
问题描述
我正在为简单的 TableView尝试 RxDataSources https://github.com/RxSwiftCommunity/RxDataSources
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
}
}
我得到了这个错误:
无法推断通用参数“Self”
ps 如您所见 - 我将 Equatable 添加到我的结构中,但它也不起作用。同时,如果我将自定义对象数组更改为字符串数组,一切都会开始正常工作。
解决方案
推荐阅读
- java - 创建物业检查分数清单
- typescript - 带有泛型方法的 Typescript 接口
- reactjs - 错误:无法下载 Chromium r686378!设置“PUPPETEER_SKIP_CHROMIUM_DOWNLOAD”环境变量以跳过下载
- r - 线性模型的事后比较
- google-data-studio - 带有连接的谷歌表的饼图
- c - C char 数组中的信息丢失
- sql - 如果 oracle 中只存在数据,如何假脱机文件?
- azure - 打开对象资源管理器详细信息时 SSMS 崩溃
- apache-nifi - NiFi 1.10 参数:如何让它们工作?
- python - Pandas DataFrame 类如列命名