I'm just a beginner in Swift coding. My idea is quite simple which is an app with two buttons. When clicked, a textfield will change its text. In the Main.StoryBoard, I add a textfield and two buttons. In ViewController.swift file. I write as this:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textfield: UITextField!
@IBOutlet weak var button: UIButton!
@IBOutlet weak var button2: UIButton!
@IBAction func action1(_ sender: UIButton) {
textfield.text="you just clicked on button1"
}
@IBAction func action2(_ sender: UIButton) {
textfield.text="you just clicked on button2"
}
}
It is supposed to be all right. However, an error appears which shows:
thread1:signal SIGABRT
in file AppDelegate.swift line:
class AppDelegate: UIResponder, UIApplicationDelegate
What is wrong with my code?
For example, an exception breakpoint will get triggered by an Unsatisfied constraints exception, but that won't crash your app. Use the exception breakpoint to gather extra information for the SIGABRT crash, and then disable it once you've solved the bug (until it's needed again).
The SIGABRT signal specifically indicates that your app called the "abort()" function, which is how apps crash themselves intentionally. The key to understanding a SIGABRT, therefore, is the error message displayed as part of the abort. In your case, you show this message in your second linked image.
A SIGABRT (signal abort) error means that the app was deliberately crashed due to some really bad problem, like a runtime error during the start-up sequence or a bad or unreadable user interface file.
If an error itself is detected by the program then this signal is generated using call to abort(). This signal is also used by standard library to report an internal error. assert() function in c++ also uses abort() to generate this signal.
You get a SIGABRT error whenever you have a disconnected outlet. Click on your view controller in the storyboard and go to connections in the side panel (the arrow symbol). See if you have an extra outlet there, a duplicate, or an extra one that's not connected. If it's not that then maybe you haven't connected your outlets to your code correctly.
Just remember that SIGABRT happens when you are trying to call an outlet (button, view, textfield, etc) that isn't there.
For me it wasn't an outlet. I solved the problem by going to the error And reading what it said. (Also Noob..)
This was the error:
And The solution was here:
Just scroll up in the output and the error will be revealed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With