Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

swift - Cannot assign value of type ‘[model]’ to type ‘Model’

I want to display the value of the table view cell on the screen. However, the following error occurs: Cannot assign value of type ‘[listenings]’ to type ‘ProfileModel’ I think there is no problem with the model.

func bindViewModel() {
        let input = ListenViewModel.input(loadData: loadData.asSignal(onErrorJustReturn: ()))
        let output = viewModel.transform(input)
        
        output.loadApplyList.map(CollectionOfOne.init).bind(to: tableView.rx.items) { tableView, index, element -> UITableViewCell in
            guard let cell = self.tableView.dequeueReusableCell(withIdentifier: "ListeningTableViewCell") as? ListeningTableViewCell else {
                return ListeningTableViewCell()
            }
            cell.listeningData = element.listen
        }.disposed(by: disposeBag)
        
    }

This is my ViewController code. Error occurs in 'cell.listingdata large = element.listen'

class target: Codable {
    let nickname: String
    let image: String
    let listening: Int
    let listener: Int
    let isMine: Bool
}

class listen: Codable {
    let listen: [listenings]
}

class listenings: Codable {
    let nickname: String
    let image: String
    let listener: Int
    let listening: Int

    let isListening: Int
}

And this is my Model code. How to solve this error?

question from:https://stackoverflow.com/questions/65540985/cannot-assign-value-of-type-model-to-type-model

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...