I have button in cell and I'm using protocols and delegates.
I get Quantity in product from api I add this Quantity in textfield. I want to Increase and Decrease same Quantity I get from api
I get Quantity here
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CartCell") as! CartTableViewCell
let Quantity = self.items[indexPath.row]["quantity"]
cell.ItemsQuantityText.text = Quantity as? String
code Protocol in tableviewcell
protocol PlusOrNegative {
func PlusandNegative (index: Int, counts: String)
}
code Button in tableviwecell
@IBAction func PlusItemsButton(_ sender: Any) {
cellPlusOrNegative?.PlusandNegative(index: index!.row, counts: "")
}
code in Viewcontroller
extension CartViewController: PlusOrNegative {
func PlusandNegative(index: Int, counts: String) {
let productid = items[index]["product_id"]
self.productId = productid as! String
print(productid!)
let product_miniWeight = items[index]["product_miniWeight"]
self.quantity = product_miniWeight as! String
print(product_miniWeight!)
}