.reloadData() 致命错误:解包可选值时意外发现 nil [英] .reloadData() fatal error: unexpectedly found nil while unwrapping an Optional value
本文介绍了.reloadData() 致命错误:解包可选值时意外发现 nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习本教程:http://jamesonquave.com/blog/developing-ios-apps-using-swift-part-3-best-practices/#comment-12898
我收到一个错误致命错误:在解包可选值时意外发现 nil".
func didRecieveAPIResults(results: NSDictionary) {
var resultsArr: NSArray = results["results"] as NSArray
dispatch_async(dispatch_get_main_queue(),{
self.tableData = resultsArr
self.appsTableView!.reloadData() // Thread 1: EXC_BAD_INSTRUCTION
})
}
这是我的 github 上的代码:https://github.com/a9austin/JamesHelloWorldTutorial/tree/master/Part1HelloWorld
Here is the code from my github: https://github.com/a9austin/JamesHelloWorldTutorial/tree/master/Part1HelloWorld
感谢大家的帮助!
推荐答案
错误的原因是你的项目在 storyboard 中没有 appsTableView.因此,它没有连接到 IBOutlet,如第 2 部分中的教程所示:
The reason for the error is your project does not have an appsTableView in the storyboard. As a result it is not connected to the IBOutlet as shown in the tutorial in Part 2:
http://jamesonquave.com/tutImg/ConnectTableView.png
这篇关于.reloadData() 致命错误:解包可选值时意外发现 nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文