【问题标题】:Instance method 'items(cellIdentifier:cellType:)' requires that 'Model' conform to 'Sequence'实例方法 'items(cellIdentifier:cellType:)' 要求 'Model' 符合 'Sequence'
【发布时间】:2020-12-03 20:25:36
【问题描述】:

我正在编写一个代码,在表格视图中显示我从服务器接收到的值。但是,会出现以下错误: 实例方法 'items(cellIdentifier:cellType:)' 要求 'Model' 符合 'Sequence' 这是我的代码。我不知道为什么会出现错误。

        rank.bind(to: tableView.rx.items(cellIdentifier: "rankingCell", cellType: RankingCell.self)) { rkc, model, cell in
            cell.nickNameLbl.text = model.nickName
            cell.profileImage.image = model.profileImage
            cell.Ranking.text = model.profileImage
        }.disposed(by: disposeBag)

这是我的视图控制器 rx部分出现错误。


struct RankingModel: Codable {
    var ranking: Int = -1
    var nickName: String = ""
    var profileImage: String = ""
    
    enum RankingModelKeys: String, CodingKey {
        case ranking
        case nickName
        case profileImage
    }
}

这是我的模型

【问题讨论】:

    标签: swift rx-swift


    【解决方案1】:

    表格视图显示值的数组(序列)。编译器告诉你你的模型不是一个数组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      • 1970-01-01
      • 1970-01-01
      • 2023-01-08
      • 2018-06-27
      • 1970-01-01
      • 2017-01-22
      相关资源
      最近更新 更多