本文介绍了在展开 Optional 值时迅速且意外地发现 nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一堂课:
class ListOfEventsController: UIViewController, UITableViewDataSource, UITableViewDelegate {
并且它包含一个函数:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("CELL") as! SingleEventCell
当我运行它时 - 它会导致一个错误,提示
and when I run it - it causes an error that says
fatal error: unexpectedly found nil while unwrapping an Optional value
但是当我转到我的故事板时,我看到:
but when I go to my story board I see:
当我点击 CELL
时,我会在它的属性中看到:
and when I click CELL
I see in its properties:
还有:
所以 CELL
的标识符已设置,但我仍然收到此错误.
so the identifiers for CELL
are set up, but I'm still getting this error.
我还能做什么?
推荐答案
- 在 Storyboard 中选择您的原型单元
- + + 打开属性检查器
- 将
CELL
写入Identifier
字段.
- In Storyboard select your prototype cell
- + + to open the Attribute Inspector
- Write
CELL
into theIdentifier
field.
然后再试一次;)
这篇关于在展开 Optional 值时迅速且意外地发现 nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!