I've got this code :
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myLabel: UILabel!
@IBAction func myFirstButtonPressed(_ sender: UIButton) {
let getButtonText : String = sender.title(for: .normal)!
myLabel.text = "Clicked \(String(describing: getButtonText))"
}
@IBAction func mySecondButtonPressed(_ sender: UIButton) {
let getSecondTitle :String = sender.title(for: .normal)!
myLabel.text = "Clicked \(String (describing: getSecondTitle))"
}}
As you can see I've created two buttons and a label and I've used the exact same instructions on them, But when I ran the simulator on Xcode, I tried clicking the second button and the label changed perfectly without any problems.
But I when I clicked the First Button, the error occurs. It is the exact same code but why is the first button giving me an error and the second button isn't?
I'm just starting to learn IOS, and the error came after the Thread : SIGBRT when I "continue program execution".
I've seen many other people posting this problem here on stack overflow but I couldn't find a solution to the problem.
Hope you guys can help me.