2016-12-25 96 views
-3

我设置一个userdefualt整数,当我继续到页面的应用程序崩溃。它显示了appDelegate,它显示“线程1:信号SIGBART”,并在调试器中显示“libC++ abi.dylib:终止于类型为NSException的未捕获的异常 (lldb)”终止与NSException类型的未捕获的异常与迅速

她是我的代码,请帮我看看这个错误:

class home: UIViewController { 
@IBOutlet weak var fiveth1: UILabel! 
@IBOutlet weak var iron1: UILabel! 
@IBOutlet weak var gold1: UILabel! 
@IBOutlet weak var ships1: UILabel! 
@IBOutlet weak var empires1: UIWebView! 

@IBOutlet weak var webViewG: UIWebView! 
override func viewDidLoad() { 
    super.viewDidLoad() 

    let htmlPath1 = Bundle.main.path(forResource: "WebViewContent2", ofType: "html") 
    let htmlURL1 = URL(fileURLWithPath: htmlPath1!) 
    let html1 = try? Data(contentsOf: htmlURL1) 

    self.webViewG.load(html1!, mimeType: "text/html", textEncodingName: "UTF-8", baseURL: htmlURL1.deletingLastPathComponent()) 


    if (Fiveth.value(forKey: "Fiveth") != nil){ 
     fiveth = Fiveth.value(forKey: "Fiveth") as! NSInteger! 
     fiveth1.text = NSString(format: "Fiveth: %i", fiveth) as String 
    } 

    fiveth1.text = "\(Fiveth)" 
} 

enter image description here enter image description here

+0

在控制台输出中,是否还有其他信息?在日志开始时,可​​能会说明导致问题的原因。 – nathan

+0

@nathan我添加了截图,这有帮助吗? –

+0

你可以在控制台中向上滚动吗?在调用堆栈的顶部应该有更详细的错误描述。 – nathan

回答

1

的问题是,你有钥匙 '帝国' 的NSUnknownKeyException。这通常是由故事板中与代码中的名称不匹配导致的。当您将该变量重命名为empires1之前,您最有可能在变量被称为empires时创建了一个出口。

要解决此问题,请断开并重新连接故事板中的插座。

+1

这正是发生了什么,谢谢你抓住我的错误! –

+0

随时将答案标记为正确,以便未来的其他人也可以从中受益。祝你的程序好运! – nathan

+2

随时可以第一次搜索。这已经被问及答复了数百次了。 – matt

相关问题