I have a table view with a table view cell. I'm trying to implement a table view with multiple cell types. When I do, I get the following error
Could not cast value of type 'UITableViewCell' (0x11e159aa0) to 'test.CourseItemTableViewCell'
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CourseItemTableViewCell
cell.refreshUI()
cell.cellIndex = indexPath
cell.dataSource = self
cell.delegate = self
cell.backgroundColor = UIColor.clear
cell.collectionView.reloadData()
return cell;
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! BookItemTableViewCell
cell.refreshUI()
cell.cellIndex = indexPath
cell.dataSource = self
cell.delegate = self
cell.backgroundColor = UIColor.clear
cell.collectionView.reloadData()
return cell;
}
How can I implement multiple cell types in the table view? I want one row to have one cell type and the other to be of another cell type.