Search code examples
iosuitableviewswiftdynamic-cast

Error Custom TableViewCell : swift dynamic_cast class unconditional


I'm getting error as swift dynamic_cast class unconditional for the following,

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
      var   cell :CustomTableViewCell = tableView.dequeueReusableCellWithIdentifier("cell") as CustomTableViewCell;    // error here

        return cell
    }

Please help me to solve this. Thank You!


Solution

  • I found the answer. Below command to be added in viewDidLoad method,you should register with your custom cell class

     self.tableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: "cell")