0
import UIKit

class LoginViewController: UIViewController {
    @IBAction func btnActionLogin(_ sender: Any?) {
        print("Why is this error?")
    }
}

After connecting the button to my view controller, when I tap the button, the app keeps crashing with an Error: (Thread 1: signal SIGABRT)

Why? I am just connecting the button from the storyboard to the code like normal..

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user3390652
  • 132
  • 1
  • 13
  • 1
    can you attach complete crash or screenShot ? – Shehata Gamal Apr 02 '18 at 17:59
  • Did you link your custom viewcontroller to the view in Interface Builder? – Cas Wolters Apr 02 '18 at 18:02
  • @CasWolters I am not quite sure what do you mean coz I have set it to be the initial View Controller in the Storyboard. If I didnt get you wrong, I have added the the Class name to the controller in the storyboard Custom Class as LoginViewController – user3390652 Apr 02 '18 at 18:07
  • Show us the crash log, it has often (if not almost all the times) the correct hints about the error. – Larme Apr 02 '18 at 18:09
  • @Larme I have found these.. Unknown class LoginViewController in Interface Builder file unrecognized selector sent to instance 0x7fccc4405e50 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController btnActionLogin:]: unrecognized selector sent to instance 0x7fccc4405e50' – user3390652 Apr 02 '18 at 18:13
  • @Larme But I am confused with this log because I have already linked the class to the controller :( – user3390652 Apr 02 '18 at 18:13
  • 1
    From it: You didn't set correctly the class of the UIViewController to `LoginViewController` (your custom one) in the Storyboard – Larme Apr 02 '18 at 18:14
  • Also make sure that no any other IBAction connected with that button action. – Mehul Sojitra Apr 03 '18 at 06:02

2 Answers2

2

Make sure the Module part is not None and set to your target name in addition to class set to Your custom class name

enter image description here

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
0

Please look at this link : Swift error : signal SIGABRT how to solve it

and follow second answer. Suspecting you have connected another action or so and might have deleted it by mistake.Attached a picture, replicating your scenraio, Please look at it

Mridul Gupta
  • 599
  • 5
  • 18