[英]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.