【发布时间】:2014-06-04 10:44:00
【问题描述】:
当为 UILabel 传递值时,会出现错误:
无法打开 Optional.None
源代码:
@IBOutlet var rowLabel : UILabel
var row: String? {
didSet {
// Update the view.
println(row)
rowLabel.text = row
}
}
当我使用新含义时,UITable 模板的标签中也会出现错误:
让 myCell : Cell = Cell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell") myCell.myLabel.text = "(indexPath.row)"【问题讨论】:
-
是编译时错误吗?
-
否,运行时:线程 1:EXC_BAD_instruction(code=EXC_1186_INVOP, subcode=0x0)
-
我编辑了我的答案,看看吧。
-
你必须用 !操作员。试试“rowLabel.text = row!”