我希望在我的
TableViewController 中选择一个单元格。 单元格的文本应通过segue传递到FirstViewController的标签上。 我总是得到下面显示的错误。
标识符是正确的。
我的代码:
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if (segue.identifier == "BackToCalculator") {
//let myRow = tableView.indexPathForSelectedRow().row+1
let vc = segue.destinationViewController as FirstViewController
vc.SelectedBundesland.text = "Test"
}
}
异常:
0x103f1f5dc: jne 0x103f1f5d0 ; swift_dynamicCastClassUnconditional + 48
0x103f1f5de: leaq 0x3364d(%rip), %rax ; "Swift dynamic cast failed"
0x103f1f5e5: movq %rax, 0xa456c(%rip) ; gCRAnnotations + 8
0x103f1f5ec: int3
0x103f1f5ed: movq %r14, %rax
问题出在哪里?
FirstViewController
的实例 - 你检查了吗?哪一行引发了异常? - Antoniolet vc = segue.destinationViewController as FirstViewController
可以工作,并且vc是FirstViewController的一个对象。但是下一行vc.SelectedBundesland.text = "Test"
不起作用:致命错误:在解包可选值时意外发现nil。 - Velocity