Ok, so here is the thing, I am migrating from objective-c to swift. There's this class where the outlets(labels) are declared, this class is a UITableViewCell type. here is the code for reference:
class DetalleCodigoCell: UITableViewCell {
@IBOutlet weak var CodigoNombre: UILabel!
@IBOutlet weak var CodigoSitio: UILabel!
@IBOutlet weak var CodigoCancelSitio: UILabel!
@IBOutlet weak var CodigoInstancia: UILabel!
@IBOutlet weak var CodigoCancelInstancia: UILabel!
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
The table is created at the main ViewController, so I reference the labels that show the data there, just like this:
class CodigosRutasViewController: UITableViewController, DZNEmptyDataSetDelegate, DZNEmptyDataSetSource, UIAdaptivePresentationControllerDelegate {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let codeCell: DetalleCodigoCell = tableView.dequeueReusableCell(withIdentifier: "CodigoCell", for: indexPath) as! DetalleCodigoCell
codeCell.CodigoNombre.adjustsFontSizeToFitWidth = true
codeCell.CodigoNombre.text = codes![indexPath.row] as? String
codeCell.CodigoSitio.text = codes![indexPath.row] as? String
codeCell.CodigoCancelSitio.text = codes![indexPath.row] as? String
codeCell.CodigoInstancia.text = codes![indexPath.row] as? String
codeCell.CodigoCancelInstancia.text = codes![indexPath.row] as? String
return codeCell
}
}
when it comes to show the data the application crashes and the following error is shown. Error: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITableViewCell 0x7fe3a042f1a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CodigoCancelInstancia.'
I do have my outlets referenced correctly inside the storyboard view, which is wierd because I don't know any other reason for this error to appear. Any idea?