xcode9:class AppDelegate:UIResponder,UIApplicationDelegate ...线程1:信号SIGABRT
问题描述:
道歉,如果这是一个明显的错误(编程新!),但我有几个问题。xcode9:class AppDelegate:UIResponder,UIApplicationDelegate ...线程1:信号SIGABRT
1:当我想负载模拟器在Xcode 9出现以下错误:
class AppDelegate: UIResponder, UIApplicationDelegate...
Thread 1: signal SIGABRT
这个问题后,才加入“猫年”标题标签和在主要故事板改变背景颜色出现。
2:当模拟器在上述更改前工作时,cat(imageView)不会出现在模拟器中?
感谢您提前提出任何建议。
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var ageTextField: UITextField!
@IBOutlet weak var resultLabel: UILabel!
@IBAction func getAge(_ sender: Any) {
if let age = ageTextField.text {
if let ageAsNumber = Int(age) {
let ageInCatYears = ageAsNumber * 7
resultLabel.text = "Your cat is " + String(ageInCatYears) + " in cat years!"
}
}
}
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.
}
}
答
,当你有这从一个视图断开插座你得到“SIGABRT”的错误。您可以通过点击故事板中的视图控制器并转到侧面板上的连接来进行检查。如果您在那里看到额外/重复的出路,这很可能是您的问题。
在您的示例中,您可能在文本字段中有一个额外的出口,或者代码中的出口引用了不同的文本字段,并且该字段不再位于故事板中。
您是否在没有空格的'ageTextField'中输入了任何Int值? –
https://stackoverflow.com/questions/45653771/uipicker-error-on-swift#comment78266823_45653771(只是我的评论,你需要使用调试器,得到真正的错误信息,然后它应该更容易理解发生了什么) – Larme