I have a label and tableview in a viewcontroller as it shown below:
I want when user taps stepper button on tableViewCell then upper label ( the number below the green button) gets updated. Yet I can't access label from my cell's class.
Any suggestion? EDIT: This is my tablevc code:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "basket", for: indexPath) as! basketcell2
cell.ConfigureCell(number: basket[basketfoodtitle[indexPath.row]]!, price: foodtitleprice[basketfoodtitle[indexPath.row]]!, foodtitle: basketfoodtitle[indexPath.row])
return cell
}
and this is my cell code:
@IBAction func steperchanged(_ sender: Any) {
NumberOfFood.text = String(Int(stepper.value))
let totalprice = Int(stepper.value)*foodtitleprice[foodtitle.text!]!
TotalPrice.text = totalprice.stringFormatedWithSepator
}
func ConfigureCell(number:Int,price:Int,foodtitle:String) {
stepper.value = Double(number)
Price.text = price.stringFormatedWithSepator
NumberOfFood.text = String(number)
self.foodtitle.text = foodtitle
let totalprice = Int(stepper.value) * foodtitleprice[foodtitle]!
TotalPrice.text = totalprice.stringFormatedWithSepator
}