0

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
George Lee
  • 814
  • 18
  • 34
  • check this [answer](https://stackoverflow.com/questions/48739894/how-to-get-indexpath-when-image-inside-cell-tapped/48740036#48740036), i think its may help you – Pratik Prajapati Jun 30 '18 at 11:16
  • Take a look at https://stackoverflow.com/questions/49832352/swift-how-to-set-uistepper-value-from-another-class/49832459#49832459 – vadian Jun 30 '18 at 15:26
  • Do you have multiple sections ? – Roohul Jun 30 '18 at 15:31

0 Answers0