I'm brand new to Swift programming. I'm doing a Udemy project and have copied all the exact same code from their "completed" project (which builds and runs fine) into my "learning" project and it fails with error:
Thread 1: "-[Destini_iOS13.ViewController IBAction:]: unrecognized selector sent to instance 0x15ff0c250"
It's a very simple program and I have no idea why the identical code works in one but not the other. Is this some broken link or resource? Any ideas?
CodePudding user response:
It sounds like a button in Main.storyboard
is linked to a method not in the ViewController
class.
To fix this -
- Right click on the button within the storyboard file to bring up a list of links/connections to it.
- Remove all items listed under
Sent Events
(I'm assuming it's just the item listed forTouch Up Inside
, but remove others as well if they're there) - Right-click and drag from the button to inside the
ViewController
file:- If the
@IBAction
function you want's already listed, drag over it until it's highlighted. - If you want to create a new
@IBAction
function, drag it to an empty line inside theViewController
class.
- If the