Keep recieaving a "Class is not key value coding-compliant"

I am recieaving a "Class is not key value coding-compliant" error concerning multiple UI objects within my Xcode project despite being correctly linked up with their corresponding variable within their view controllers.

I suspected it had something to do with the project file itself experiencing a bug but when I transfer all my code and view controllers to a new project the error continued to appear.

For example, within one view controller I am attempting to create a password login page, however when I enter the page within the simulator it crashes and presents the following error in the AppDelegate next to @main


class EviPasswordVC: UIViewController {
  @IBOutlet weak var txtPassword: UITextField!
  @IBOutlet weak var LabError: UILabel!
   
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
  }
   
  @IBAction func btnEnter(_ sender: UIButton) {
    if txtPassword.text == "1234" {
      LabError.text = "Success"
    performSegue(withIdentifier: "gotoEvidence(Menu)", sender: self)}
//If the text entered into 'txtPassword' = 1234, 'LabError' will display "Success' and the next page will be shown. 

      else {
        LabError.text = "Failed"}
//If the text entered into 'txtPassword' does not equal '1234', 'LabError will display "Failed"
    }
}

Thread 1: "[<UIViewController 0x7fa417a1f180> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key LabError."

This error continued to persist even when I ensured the label had the variable name 'LabError' within my view controller. This code use to work, however when I started organising these sections of code under different classes corresponding to different view controllers errors like this started to occur, even when I reverted back to their orginal position under the same class and view controller.

If anyone knows the possible cause for this error and any way to resolve it can they please respond, it would be extremely appreicated.

Thanks.

when I transfer all my code and view controllers to a new project

How did you do that ? Copy and paste between projects or between classes may cause inconsistent object ID references.

Connections may appear correct but be corrupted. Do a test in your project:

  • disconnect all IBOutlets
  • reconnect
  • Do a Clean Build Folder.

What do you get ?

I copied and pasted the view controller which was automatically generated by the new project to create multiple view controllers. I then pasted the UI objects from the pervious project into the new project. I also created seperate swift files for each new view controller unlike my pervious project and transfered the code corresponding to each specific one. However for the example I provided I did not transfer the UI objects from the old project, only the code.

I did the things you said and the same error still occured.

It would be necessary to have a look at the whole project. If you want, post an email address here so that we can share files.

Accepted Answer

Thread 1: "[<UIViewController 0x7fa417a1f180> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key LabError."

Read that error carefully. It’s not saying that EviPasswordVC is not KVC compliant for LabError, it’s saying that UIViewController is not KVC compliant for that property. That means that IB doesn’t realise that your view controller is of type EviPasswordVC; it still thinks it’s of type UIViewController.

In IB, select your view controller, choose View > Inspectors > Identity and make sure that the Class field is set to EviPasswordVC.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I did what you said Eskimo and intially it did not work, however when I decided to retype the name 'EviPasswordVC' into the view controller ClassField, a checkbox with the text 'Inherit Module from Target' switched from being unticked to ticked and the error stopped. I am unsure why it did not do this intially when I first renamed the view controller but either way the error is gone now.

Thanks for the help Eskimo and Claude31, really appreciate it.

Droopy2011 wrote:

the error is gone now.

Yay!

Claude31 wrote:

In this case, it should be impossible to connect the IBOutlet, shouldn’t it ?

Right. However, I occasionally see situations where the class name gets lost while the connections persist, resulting in this error. Based on Droopy2011’s comments, it seems like that this is related to some sort of failed renamed but *shrug*

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Keep recieaving a "Class is not key value coding-compliant"
 
 
Q