I can call scheduleCellEntries[indexPath.row] in the cellForRowAtfunction but in the @IBAction function that is linked to a button it's not possible that way.
When I run the code I get the following error: Use of unresolved identifier 'indexPath'; did you mean 'IndexPath'?
I tried to do do it the same way as recommended in the error, but that didn't work either.
Array:
var scheduleCellEntries: [ScheduleCell]! = [ScheduleCell(id: 1, textButtonState: false, timeButtonState: false, text: "Appointment", time01: "07:30", time02: "12:30")
cellForRowAt Function:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == scheduleTableView {
let cell = tableView.dequeueReusableCell(withIdentifier: "scheduleCell", for: indexPath) as! scheduleTableViewCell
if scheduleCellEntries[indexPath.row].timeButtonState == false{
cell.scheduleDateCheckBox.isSelected = false
}else{
cell.scheduleTextCheckBox.isSelected = true
}
if scheduleCellEntries[indexPath.row].textButtonState == false{
cell.scheduleTextCheckBox.isSelected = false
}else{
cell.scheduleTextCheckBox.isSelected = true
}
return cell
}
@IBActionFunction:
@IBAction func timeCheckboxIsPressed(_ sender: UIButton) {
if sender.isSelected {
sender.isSelected = false
scheduleCellEntries[indexPath.row].timeButtonState = false
} else {
sender.isSelected = true
scheduleCellEntries[indexPath.row].timeButtonState = true
}
}
I would like to assess the array in that function so that whenever the button state is switched, the boolean value in the array changes as well.
Aucun commentaire:
Enregistrer un commentaire