This class is not key value coding-compliant

My environment is as follows: macOS Catalina Xcode 12 StoryBoard Single Window/View Controller - the view controller has custom code to populate a tableView in the View Controller The tableView has 7 columns and is populated from a SQLite table. The tableView displays data for 6 of the 7 columns. On the last column I get the following error: valueForUndefinedKey:]: this class is not key value coding-compliant for the key itemUsedLast.

I have searched for information on this error and what I have found is it seems to be saying that for the field itemUsedLast can not find an outlet? But in the case for a tableview the only IBOutlet is one for the entire tableView. Also, the identifiers in the storyboard match the code in the custom view controller.

I have completed several tableViews before and have not run into this issue.

I have tried several remedies but none resolved this issue.

Any thoughts on how to debug this further or resolve this will be appreciated.


If you haven’t already done so, reading the following guides are worth the effort:

This is resolved. The problem was a mis-match in the names in NSObject, field identifiers and IB.

So as an example.

class Item: NSObject {
    @objc   var itemNumber: String? = ""
    @objc   var itemLastused: Date?

var items:[Item] = []
let item = Item()
item.itemNumber = "100"
item.itemLastused = Date()
let valueForNumberKey = items[0].value(forKey: "itemNumber")
let valueForDateKey = items[0].value(forKey: "itemLastused

Besides the names matching here they also need to match in the IB.