[英]XCode 8: Unexpectedly found nil while unwrapping an optional value
Created a new project on XCode 8, installed 1 pod that is of Alamofire
and then checked my app if everything is ok, it ran well. 在XCode 8上创建了一个新项目,安装了一个
Alamofire
,然后检查了我的应用程序是否一切正常,它运行良好。 And then I hooked up a tableView
in the interface builder as I would previously do in earlier versions of XCode, defined the classes, connected the tableviewCell and when I run, the app crashed on my iPhone 5s, being used as my test device. 然后,我像以前在XCode的早期版本中一样,在界面生成器中连接了
tableView
,定义了类,连接了tableviewCell,当我运行时,该应用程序在iPhone 5s上崩溃,被用作我的测试设备。 Moreover, there is no error line that I could encounter or shown to the console. 而且,没有错误线可以遇到或显示在控制台上。 Also, I have not force unwrapped any optional.
此外,我还没有强行打开任何可选的包装。 The code crashes before it could reach
viewDidLoad()
method in the starting viewController. 代码在到达启动viewController中的
viewDidLoad()
方法之前崩溃。
Set identifier in the Storyboard/xib of the Custom Cell like below: 在自定义单元的情节提要/ xib中设置标识符,如下所示:
Use same identifier in tableView delegate method cellForRowAtIndexPath
: 在tableView委托方法
cellForRowAtIndexPath
使用相同的标识符:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCellWithIdentifier("TableViewCell") as TableViewCell
//related code here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.