Could not cast value of type ‘UITableViewCell’ to ‘(AppName).(CustomCellName)’

There are a few things you can check in this scenario:

  1. See if your table is linked to your class, usually by @IBOutlet weak var tableView: UITableView!

  2. Register custom table view cell: self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
    Note that you use “UITableViewCell” and the identifier “cell” even if your custom cell has different class and id.

  3. Dequeue your cell in cellForRowAtIndexPath: let cell: MessageCell = self.tableView.dequeueReusableCellWithIdentifier("messageCell") as! MessageCell
    Now you use the correct cell identifier.

Leave a Comment