簡體   English   中英

實例方法 'items(cellIdentifier:cellType:)' 要求 'Model' 符合 'Sequence'

[英]Instance method 'items(cellIdentifier:cellType:)' requires that 'Model' conform to 'Sequence'

我正在編寫一個代碼,在表格視圖中顯示我從服務器收到的值。 但是,會出現以下錯誤: 實例方法 '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)

這是我的 viewController 的 rx 部分出現錯誤。


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

這是我的 model

表格視圖顯示值的數組(序列)。 編譯器告訴您您的 model 不是數組。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM