1
我有一个可以接受泛型类型的自定义单元。Swift 3 Generic不能转换UITableViewCell类型的值
class MyCell<T>: UITableViewCell where T: MyCellDataSource, T: MyCellDelegate
如何使用它,或者在转出单元时输入或推断它?
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
你可以做'让电池= tableView.dequeueReusableCell(withIdentifier: “细胞”,为:indexPath)为! MyCell'我认为 – Eric
不行,那不行。这是通常的方式,我试过了。 – Axel
您不能转换为未指定的泛型类型,只能指定其具体版本,即指定了泛型'T'。沿着'let cell = tableView.dequeueReusableCell(withIdentifier:“cell”,for:indexPath)行的东西就像!了myCell'。 –
dfri