tiamat
tiamat

Reputation: 971

Swift setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key

I removed manually from my Xcode project Alamofire POD and since this time, I have errors in some UIViewControllers on any UIButton IBOutlet added.

I have the following error:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btListOrdo

I tried to create a new UIViewController and link it to my StoryBoard but I have the same error....

I'm adding the following IBOutlet

@IBOutlet weak var btListOrdo: UIButton!

Notice that those links worked properly before the POD removal, I may have removed something mandatory but I'm not able to find it.

here is the screenshot of the referencing outlets of my button:

enter image description here

I also tried to clean the project, cleaned the Build Folder, deleted Derived Data, Reset Content and Settings of the simulator but same result...

Upvotes: 18

Views: 50520

Answers (7)

Andrei Mistetskii
Andrei Mistetskii

Reputation: 69

if you have several targets , check that you selected needed target membership for all your source files. it also could raise such kind of exception.

Upvotes: 0

miralgondaliya
miralgondaliya

Reputation: 21

I remove the button delegate and the problem fixed, the issue was about the button delegate. Check this image

Image

Upvotes: 0

Papon Smc
Papon Smc

Reputation: 688

if you tick checkbox inhertite done should check key in log alert or look in source and then delete in alert ui

in same picture

try check.

if you find alrt same picture delete it.

enter image description here

Upvotes: 11

Vladimir Kuzomenskyi
Vladimir Kuzomenskyi

Reputation: 531

I had the same issue while using popular Rswift library to presenting view controller that uses nib.

So I just had to replace

let productCardVC = ProductActionVC(nib: R.nib.productCardVC)

with

let productCardVC = ProductCardVC(nibName: "ProductCardVC", bundle: nil)

and all starts to work perfectly well

Upvotes: 0

Jon F
Jon F

Reputation: 11

Just to throw in my 2c, the way I fixed this error was by checking my reference outlets and making sure I didn't have any that were just floating, not connected to anything. I think the swift compiler was getting angry at me for that.

Upvotes: 0

Sponxie
Sponxie

Reputation: 71

Check that your class is the same that you use in storyboard

enter image description here

Upvotes: 7

Elliott D'Alvarez
Elliott D'Alvarez

Reputation: 1237

Okay I just faced the same issue and it was due to having multiple targets. I couldn't figure out why it would run perfectly fine in some instances, yet not others. The issue is actually with the Module definition on the view controller, I'm guessing that this may explain why when you completely recreate the controller the issue seems magically fixed. On mine I had the Module set to one of my targets, so when I ran a second target it wasn't associated. If you have multiple targets make sure you empty the Module box on the VC that crashes (on your storyboard) and tick Inherit Module From Target.

Hope this helps

enter image description here

Upvotes: 49

Related Questions