私は、ユーザーが複数のセルをタップして選択する必要があるアプリケーションを作っています。セルをタップすると、.Checkmarkのアクセサリーアイテムが表示されます。何らかの理由しかし、私は試してみて、そのVCにアプリがクラッシュを取得し、(チェック[indexPath.row]場合!)が、私は8行目に次のエラーメッセージを取得するたび:indexpathの範囲外のインデックス
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell: InstrumentTableCell! = tableView.dequeueReusableCellWithIdentifier(identifier) as? InstrumentTableCell
cell.configurateTheCell(recipies[indexPath.row])
if !checked[indexPath.row] {
cell.accessoryType = .None
} else if checked[indexPath.row] {
cell.accessoryType = .Checkmark
}
return cell
}
をし、
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
tableView.deselectRowAtIndexPath(indexPath, animated: true)
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
if cell.accessoryType == .Checkmark {
cell.accessoryType = .None
checked[indexPath.row] = false
} else {
cell.accessoryType = .Checkmark
checked[indexPath.row] = true
}
}
}
OK、あなたの 'checked'メソッドはどのように見えますか? – pbodsk
pbodskチェックされたメソッドを追加する質問が更新されました:) – zach2161
ah ... OKですので、 'checked'は、行がチェックされているかどうかを格納する配列です。 – pbodsk