Could not cast value of type 'UITableViewCell' to '(AppName).(CustomCellName)' Could not cast value of type 'UITableViewCell' to '(AppName).(CustomCellName)' xcode xcode

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! MessageCellNow you use the correct cell identifier.


Register your CustomCell in viewDidLoad() method:

self.tableView.register(CustomCell.self, forCellReuseIdentifier: "Cell")


I had same problem , I set custom class for cell but forgot to set moduleenter image description here

after selecting module like this , it worked

enter image description here