0

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:

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Amrmsmb
  • 1
  • 27
  • 104
  • 226
  • Did you control drag from viewController to the button in storyboard? – Fattaneh Talebi Jun 19 '17 at 07:03
  • right click on your button in storyboard and check if all actions set in a right way. it is possible that something happend there, – Mina Jun 19 '17 at 07:06
  • yes, first i named the ban "sd" and when I dragged it to VC file it did not get linked, so i decided to remove the name and then give it a new name which is mentioned in my question, ..at run time i got the error i posted – Amrmsmb Jun 19 '17 at 07:06
  • I'm sure that you still have the ```sd``` connection on your button. check it again please. – Mina Jun 19 '17 at 07:07
  • @user2121 Right click on button and check for how many IBAction is displayed for a button. – Ashok Londhe Jun 19 '17 at 07:10

3 Answers3

3

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

Burnie777
  • 395
  • 5
  • 18
0

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.

Salman Ghumsani
  • 3,647
  • 2
  • 21
  • 34
0

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

Mina
  • 2,167
  • 2
  • 25
  • 32