Ios 无内容的tableview单元格

Ios 无内容的tableview单元格,ios,arrays,swift,uitableview,Ios,Arrays,Swift,Uitableview,我的表视图正在填充,但单元格上没有内容 当我尝试将这一行//cell.textlab?.text=todoItems[indexPath.row]放入时。我得到了这个错误 您分配了错误的类型。你应该这样做: let item = todoItems[indexPath.row] cell.textLabel?.text = item.itenName cell.textLabel?.text = todoItems[indexPath.row].itenName 您可以找到todoItems

我的表视图正在填充,但单元格上没有内容 当我尝试将这一行
//cell.textlab?.text=todoItems[indexPath.row]
放入时。我得到了这个错误


您分配了错误的类型。你应该这样做:

let item = todoItems[indexPath.row]
cell.textLabel?.text = item.itenName
cell.textLabel?.text = todoItems[indexPath.row].itenName

您可以找到todoItems[indexPath.row]的类是
DataSource
with

print(todoItems[indexPath.row].classForCoder)
cell.textLabel?的类别是
String
。 所以您分配了错误的类型。你应该这样做:

let item = todoItems[indexPath.row]
cell.textLabel?.text = item.itenName
cell.textLabel?.text = todoItems[indexPath.row].itenName

你应该这样做

let item = todoItems[indexPath.row] as DataSource
cell.textLabel?.text = item[indexPath.row].itenName

请在代码中提供解释。这个回复,就像现在一样,不是一个答案,正在被删除。我已经用我的代码添加了一个解释。你有更多的评论吗?