无法将“UITableViewCell”(0x10c111c68)类型的值转换为子类

Abr*_*m P 1 uitableview ios swift

我正在尝试构建一个相当直接的数据表,并遵循本教程:http : //www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift

我有以下自定义单元格类:

import Foundation
import UIKit

class WorkItemCell: UITableViewCell {
  @IBOutlet var titleLabel: UILabel!
}
Run Code Online (Sandbox Code Playgroud)

以及我的 TableClass 中的以下函数:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCellWithIdentifier("WorkItemCell") as! WorkItemCell
    cell.textLabel?.text = self.work[indexPath.row]["name"] as! String
    return cell
}
Run Code Online (Sandbox Code Playgroud)

这导致:

Could not cast value of type 'UITableViewCell' (0x10c111c68) to 'proj.WorkItemCell' (0x10a84c4c0).

为什么?我该如何解决?

Abr*_*m P 5

最终,我意识到问题是我UITableViewCell.self在我的中使用tableView.registerClass,改变它以WorkItemCell.self解决问题