今天我遇到了一个有趣的问题,其中一个nil可选项被解包并且错误未在调试面板中写入。
以下示例对var'datasource'
的值为nillet indexPath = (datasource?.cellAtIndexPath(TableViewRow.Social.indexPath, forEventDetail: self) as! EventDetailSocialTableViewCell).collectionView.indexPathForCell(collectionViewCell)! //[This line highlighted red with the caption EXC_BAD_INSTRUCTION]
调试面板打印:(lldb)
在这里,您可以看到我们是否将调试面板的分割线打印得很好。
let tableViewCell = datasource?.cellAtIndexPath(TableViewRow.Social.indexPath, forEventDetail: self)
let indexPath = (tableViewCell as? EventDetailSocialTableViewCell)?.collectionView.indexPathForCell(collectionViewCell)
let socialOption = socialOptions[indexPath!.row] //[This line highlighted red with the caption EXC_BAD_INSTRUCTION]
调试面板打印:致命错误:在解包可选值(lldb)时意外发现nil
有没有人在Swift 2.2之前看过这个问题(哪里没有打印错误)?值得提出作为一个错误?