[英]Thread 1: signal SIGABRT AppDelegate.swift
我试着编译我的第一个iOS Hello应用程序。
ViewController.swift
//
// ViewController.swift
// My First Project
import UIKit
class ViewController: UIViewController {
// Declare components
@IBOutlet weak var inputLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func submitBtn(_ sender: Any) {
inputLabel.text = "Hello World"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
让Build Succeeded
但是大约5秒后,我得到了这个
0x0000000103915f69 -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x000000010770f723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19 FrontBoardServices 0x000000010770f59c -[FBSSerialQueue _performNext] + 189
20 FrontBoardServices 0x000000010770f925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x0000000105ff0311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x0000000105fd559c __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x0000000105fd4a86 __CFRunLoopRun + 918
24 CoreFoundation 0x0000000105fd4494 CFRunLoopRunSpecific + 420
25 UIKit 0x00000001039147e6 -[UIApplication _run] + 434
26 UIKit 0x000000010391a964 UIApplicationMain + 159
27 My First Project 0x0000000102e6db3f main + 111
28 libdyld.dylib 0x0000000106f7868d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我曾经有这个
我更新了这个
重新运行并仍在发生......
重新运行并仍在发生......
问题在您的标签中,我100%确定您删除了一些插座参考,并忘记从故事板中删除连接。 请检查
代码和屏幕截图不一致。
label.text = "Hello World"
inputLabel.text = "Hello World"
错误消息是:
...不符合键值标签的键值。
因此,最有可能在您的实际代码中, IBOutlet
被命名为inputLabel
但在Interface Builder中, label
的(死)连接会导致崩溃。
解:
Main.storyboard
和画布中的ViewController
。 label
的连接。 inputLabel
。 其他人已经提到了关于网点及其参考资料,你必须确保它们已经正确地连接到你的班级。
我想到的另一个可能的情况可能是这样:如果您在故事板中的identity inspector
选项卡中的user defined Rundtime Attributes
下user defined Rundtime Attributes
标签的键路径,并且如果未定义该键,您将在控制台中收到此消息错误日志:
...this class is not key-value compliant for the key label.
例如,在下面的图像中,您会看到一个键路径popupTitle
如果它没有在您的标签类中定义,它将收到此错误消息。 在某些情况下它会崩溃。 确保本节中没有额外的密钥路径。
这发生在我身上,因为我正在从另一个项目复制一些文件(并重命名它们)。 Xcode感到困惑,显然在连接插座时遇到了困难。 在Xcode中,一切看起来都很好,但我遇到了与运行时问题相同的错误,没有进一步的解释。
我通过清理项目并删除派生数据来修复它。 一如既往.. :/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.