简体   繁体   中英

Signal Abort(SIGABRT) exception in Xcode

Recently I've been trying to learn how to create apps in my free time. I've been following Apple's Swift documentation along with their tutorials on creating apps. After I finished the "Connect the UI to Code" tutorial, I ran the simulator, only to receive a SIGABRT exception in my "AppDelegate" Class . I looked at the console and it says:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FoodTracker.ViewController nameTextField:]: unrecognized selector sent to instance 0x7fb572d0a040'

I even replaced my original file with Apple's file just to see if there were any differences (there weren't, with the exception of a few extra comments). Here's my ViewController class file:

class ViewController: UIViewController, UITextFieldDelegate {

//MARK: Properties

@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var mealNameLabel: UILabel!


override func viewDidLoad() {
    super.viewDidLoad()

    // Handle the text field’s user input through delegate callbacks.
    nameTextField.delegate = self

}

//MARK: UITextFieldDelegate

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    // Hide the keyboard.
    textField.resignFirstResponder()
    return true
}

func textFieldDidEndEditing(_ textField: UITextField) {
    mealNameLabel.text = textField.text
}  

}

As I mentioned in my comment, you have inconsistent Storyboard to code bindings. The screenshot below shows you the exclamation points where Xcode complains. Delete and re-add them.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM