class is not key value coding-compliant for a nonexistent IBAction

3.7k Views Asked by At

I have created as swift project in Xcode, and i added Button to the storyboard. The IBAction of that button is named "WhenButtonPresed", but when I run the App it gets crashed and i got the below posted error despite i do not have any IBAction called "sd"

code:

2017-06-19 08:46:21.909 Test_SWIFT_FMDB-1[958:18819] 
<CATransformLayer: 0x7fc353d2e1d0> - changing property 
contentsGravity in transform-only layer, will have no effect
2017-06-19 08:46:22.188 Test_SWIFT_FMDB-1[958:18819] *** Terminating 
app due to uncaught exception 'NSUnknownKeyException', reason:   
'[<Test_SWIFT_FMDB_1.ViewController 0x7fc353d25fa0> 
setValue:forUndefinedKey:]: this class is not key value coding-
compliant for the key sd.'

*** First throw call stack:

3

There are 3 best solutions below

1
Burnie777 On BEST ANSWER

I have found this error a couple of times and it seems to be a configuration on the UI that is not correct. It seems to happen when I copy a viewcontroller which has certain links to current objects which I used on the original viewcontroller...

How I correct it:

  1. I select the ViewController in question

enter image description here

  1. I check for exclamation marks and remove it

enter image description here

Hope this helps

0
Salman Ghumsani On

Check your connections in Interface Builder. You're probably referring to a non-existent IBOutlet or IBAction.

Also, make sure you don't make double connections in viewcontroller from storyboard from IBOutlet or IBAction.

0
Mina On

It must be something like this in the storyboard. Just remove the sd action. if you only remove it in code, the connection is still alive and it cause a crash in runtime.

In your case: i add the sd action and then remove it from code and add another action with another name(press). but as you can see the sd action is still exist.

enter image description here