I am having big troubles trying to get a UIStepper to give me its indexPath.row and indexPath.section for their use with a two-dimensional array. I have looked for a couple of hours and haven't found a solution online, so I thought I'd ask. Please see this code:
@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
}
Any help would be greatly appreciated.