出乎意料的是,在解开可选价值swift nil时出乎意料地找到了



我的代码

我尝试在母猪中搜索此问题,评论部分现在无法避免,我的Xcode是7.1和iOS 9.0模拟器致命错误:在解开可选值时出乎意料地发现了零(LLDB)

如何解决这个问题?谢谢你

我删除了!,但Xcode建议我附加为........

var cell:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(cellId)! as UITableViewCell

太多代码。

let cell = UITableViewCell(style: .Default, reuseIdentifier: cellId)

除非您的TableView的ReuseIdentifier不正确,否则它不会零。

我将使用

let cell = tableView1.dequeueReusableCellWithIdentifier(cellId, forIndexPath: indexPath) as! UITableViewCell

这意味着具有正确ID的单元将被放置在UITableView上的正确空间中。另外,我认为在前面有tableView可能会导致错误,因此我将其更改为tableView1

最新更新