Я делаю приложение, которое требует, чтобы пользователь использовал несколько ячеек, чтобы выбрать их. когда они нажимают на ячейку, появится аксессуар .Checkmark. По какой-то причине, хотя всякий раз, когда я пытаюсь добраться до этого VC сбои приложения, и я получаю следующее сообщение об ошибке на линии 8 (если флажок [indexPath.row]!): Индекс за пределами диапазона для indexPath swift
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
}
}
}
ОК, как выглядит ваш метод 'checked'? – pbodsk
pbodsk Я обновил вопрос, чтобы добавить проверенный метод: – zach2161
ah ... ОК, поэтому 'checked' - это массив, в котором вы храните, проверена ли строка, правильно ли это? – pbodsk