I want to use a UIStepper in each of my tableview rows which updates a count in that tableview row. For some reason my implementation right now updates the tableview row label count but for some reason it also updates the label a couple of rows down as well.
This code is in the viewcontroller
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableview.dequeueReusableCell(withIdentifier: "add-item", for: indexPath) as! InventoryTableViewCell
cell.productLabel.text = inventoryObject[indexPath.section].sectionItems[indexPath.row]
cell.priceLabel.text = String(inventoryObject[indexPath.section].sectionPrices[indexPath.row])
return cell
}This code is in the inventorytableview cell which each outlet is connected to the corresponding component.
import UIKit
class InventoryTableViewCell: UITableViewCell {
@IBOutlet var productLabel: UILabel!
@IBOutlet var priceLabel: UILabel!
@IBOutlet var quantityStepper: UIStepper!
@IBOutlet var quantityLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
/
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
/
}
@IBAction func quantityStepperAction(_ sender: UIStepper) {
quantityLabel.text = sender.value.description
}
}Any help would be great thanks.