无法解决错误:线程1:在swift XCODE中发出SIGABRT信号 [英] Can't resolve error: Thread 1: signal SIGABRT in swift XCODE
问题描述
我有一个常见的错误 - 线程1:信号SIGABRT。虽然我无法解决这个问题。我已经研究了更多关于这个错误的信息,我找到了类似的东西:只有当你在一个不存在的插座上调用时才会发生这个错误。我回头看了我的代码,寻找一些按钮,标签,图像或任何我不想要的东西,我只是找不到任何bug的踪迹!如果有人能发现一个错误或任何东西,这将是伟大的。谢谢!
I have the common error - "Thread 1: signal SIGABRT". Although I can't resolve this. I have researched more about this error, I found stuff like: This error only happens when you are calling on an outlet that doesn't exist. I've looked back into my code looking for some button, label, image or anything that I do not want, I just can't find any trace of the bug! If anyone can spot a bug or anything, that would be great. Thanks!
这是我的代码
import UIKit
class ViewController: UIViewController {
//Useful Variables
var cashCount:Int = 0
var cashIncome:Int = 1
//The cash displaying Outlets
@IBOutlet weak var errorDisplay: UILabel!
@IBOutlet weak var cashDisplayLabel: UILabel!
@IBOutlet weak var cashIncomeDisplayer: UILabel!
//The other outlets
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//When the cash is clicked call this func
@IBAction func CashClicked(_ sender: Any) {
cashCount += cashIncome
cashDisplayLabel.text = "Cash: $\(cashCount)"
}
//The store functions
@IBAction func BuyFoodFUNC(_ sender: Any) {
if cashCount >= 10 {
errorDisplay.text = "Success!"
cashCount -= 10
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
@IBAction func BuySubFUNC(_ sender: Any) {
if cashCount >= 20 {
errorDisplay.text = "Success!"
cashCount -= 20
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
@IBAction func BuyCarFUNC(_ sender: Any) {
if cashCount >= 800 {
errorDisplay.text = "Success!"
cashCount -= 800
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
@IBAction func BuyRVFUNC(_ sender: Any) {
if cashCount >= 1000 {
errorDisplay.text = "Success!"
cashCount -= 1000
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
@IBAction func BuyLapTopFUNC(_ sender: Any) {
if cashCount >= 900 {
errorDisplay.text = "Success!"
cashCount -= 900
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
@IBAction func BuyPhoneFUNC(_ sender: Any) {
if cashCount >= 700 {
errorDisplay.text = "Success!"
cashCount -= 700
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
@IBAction func UpgradeCashINCOME(_ sender: Any) {
if cashCount >= 10 {
errorDisplay.text = "Success!"
cashCount -= 10
cashIncome += 1
cashIncomeDisplayer.text = "Income: $\(cashIncome)"
} else {
errorDisplay.text = "Sorry, Not Enough Funds!"
}
}
}
这是截图
此外,如果您更改了名称一个插座,你将有如下图所示的东西。按x删除该连接并将圆圈拖到右侧并重新连接。
Also, if you changed the name of an outlet, you will have something like the image below. Press the x to delete that connection and drag the circle to the right of it and reconnect it.
这篇关于无法解决错误:线程1:在swift XCODE中发出SIGABRT信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!