Swift错误:信号SIGABRT如何解决它 [英] Swift error : signal SIGABRT how to solve it
问题描述
我只是Swift编码的初学者。我的想法很简单,这是一个带有两个按钮的应用程序。单击时,文本字段将更改其文本。
在Main.StoryBoard中,我添加了一个文本字段和两个按钮。
在ViewController.swift文件中。我这样写:
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
thread1:signal SIGABRT
在文件AppDelegate.swift行:
in file AppDelegate.swift line:
class AppDelegate: UIResponder, UIApplicationDelegate
我的代码出了什么问题?
What is wrong with my code?
推荐答案
我通过清理项目和重建来解决问题。
I solve the problem by clean the project and rebuild.
要清理项目,请执行到 MenuBar:产品 - >清洁
To clean the project go to MenuBar: Product -> Clean
然后重建只需像往常一样点击运行按钮
Then to rebuild just click Run button as usual
这篇关于Swift错误:信号SIGABRT如何解决它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!