It has happened to us all: you’re in a storyboard, you’re using the Assistant Editor, you want to control-drag from a button into your code and create an action.
But sadly you forget to select “Action” from the drop down menu and instead create an outlet.
No biggie you think, deleting the outlet code. You go back and create the action properly, run the app… and get an error message such as this one:
*** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key badAction.’
Yikes! Unless you’re using Version Control, there is no way to undo adding that bad outlet. So you ask yourself: Will I have to start from scratch, or is there a way to fix your app?
Yes this is fixable – all we need to do is examine our storyboard file in Source Code mode, then find the problem and eliminate it. Here’s how you do it:This content is for members only.
Once you’re done, run the app again and all should be fine.
To display the storyboard in the visual editor again, just control-click the file file again, and select “Open as – Interface Builder, iOS Storyboard”.