我有一个将mode
更改为其他值的按钮,然后我尝试使用以下代码检查mode
中的值:
override func ViewDidLoad () { super.ViewDidLoad()
println("Selected mode is \(mode)")
switch mode {
case "A":
SelectedList = AformulesList
println("Selected list is A")
case "G":
SelectedList = GformulesList
println("Selected list is G")
case "P":
SelectedList = PformulesList
println("Selected list is P")
case "C":
SelectedList = CformulesList
println("Selected list is C")
default:
SelectedList = AformulesList
println("Nope, it doesn't works yet")
因此,AformulesList,GformulesList,PformulesList和CformulesList是具有单元格标签文本的数组。在下一段代码中,我做了一件简单的事情:
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! formule
// Configure the cell...
cell.formuleLabel!.text = self.SelectedList[indexPath.row]
但是当我编译我的代码并点击按钮时出现错误EXC_BAD_INSTRUCTION并且输出中出现此错误:致命错误:数组索引超出范围
甘蔗帮我解决这个问题吗?谢谢你的帮助!