У меня большие проблемы с попыткой заставить UIStepper предоставить мне его indexPath.row и indexPath.section для их использования с двумерным массивом. Я искал пару часов и не нашел решения в Интернете, поэтому решил спросить. Пожалуйста, посмотрите этот код:
@objc private func stepperValueChanged(_ sender: UIStepper!){
print("Stepper \(sender.tag) clicked. Its value \(sender.value)")
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: ContactCell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! ContactCell
cell.myUIStepper.tag = indexPath.row
cell.myUIStepper.addTarget(self, action: #selector(stepperValueChanged), for: .valueChanged)
cell.cellDelegate = self
let contact = twoDimensionalNamesArray[indexPath.section].names[indexPath.row]
let contactInt = intsArray[indexPath.section][indexPath.row]
cell.textLabel?.text = ("\(contact.name): \(contactInt)")
print(contact.name)
cell.accessoryView?.tintColor = contact.isFavorited ? .blue : .gray
if showIndexPath == true {
cell.textLabel?.text = "\(contact.name) -- \(indexPath.section), \(indexPath.row)"
}
return cell
}
Любая помощь будет принята с благодарностью.