my table view cell
class Service1TableViewCell: UITableViewCell {
@IBOutlet weak var quantityStepper: UIStepper!
@IBOutlet weak var Service1image: UIImageView!
@IBOutlet weak var serviceTitle: UILabel!
@IBOutlet weak var pricingInfo: UILabel!
@IBOutlet weak var stepperLabel: UILabel!
func setService1(Dry: Service1){
Service1image.image = Dry.service1image
pricingInfo.tag = Dry.service1Pricing
serviceTitle.text = Dry.service1Title
}
//save data from each cell and multiply for total service
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
@IBAction func valueChanged(_ sender: AnyObject) {
print("Method .valueChanged activated")
//Update stepperlabel
stepperLabel.text = String(Int(quantityStepper.value))
}
}
ViewController
class Service1ViewController: UIViewController {
@IBOutlet weak var service1TableView: UITableView!
@IBOutlet weak var service1Total: UILabel!
var Dry: [Service1] = []
var step = [Stepper]()
override func viewDidLoad() {
super.viewDidLoad()
Dry = Options()
}
func Options() -> [Service1]{
var dryOptions: [Service1] = []
let option1 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option2 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option3 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option4 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option5 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option6 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option7 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option8 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option9 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option10 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option11 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option12 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option13 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option14 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option15 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option16 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option17 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option18 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option19 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option20 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option21 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option22 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option23 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option24 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option25 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option26 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option27 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option28 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option29 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option30 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
let option31 = Service1(titled: "Test", pricing: Int(5.29), image: #imageLiteral(resourceName: "Test"))
dryOptions.append(option1)
dryOptions.append(option2)
dryOptions.append(option3)
dryOptions.append(option4)
dryOptions.append(option5)
dryOptions.append(option6)
dryOptions.append(option7)
dryOptions.append(option8)
dryOptions.append(option9)
dryOptions.append(option10)
dryOptions.append(option11)
dryOptions.append(option12)
dryOptions.append(option13)
dryOptions.append(option14)
dryOptions.append(option15)
dryOptions.append(option16)
dryOptions.append(option17)
dryOptions.append(option18)
dryOptions.append(option19)
dryOptions.append(option20)
dryOptions.append(option21)
dryOptions.append(option22)
dryOptions.append(option23)
dryOptions.append(option24)
dryOptions.append(option25)
dryOptions.append(option26)
dryOptions.append(option27)
dryOptions.append(option28)
dryOptions.append(option29)
dryOptions.append(option30)
dryOptions.append(option31)
return dryOptions
}
}
extension Service1ViewController: UITableViewDataSource, UITableViewDelegate{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return Dry.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let Dry1 = Dry[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "Service1Cell") as! Service1TableViewCell
cell.setService1(Dry: Dry1)
cell.stepper = step[indexPath.row]
return cell
}
// send selected data to cart
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
(cart tableView) service choice cell
class CartTableViewCell: UITableViewCell {
@IBOutlet weak var serviceChoiceImage: UIImageView!
@IBOutlet weak var serviceChoiceTitle: UILabel!
@IBOutlet weak var serviceChoiceAmount:UILabel!
@IBOutlet weak var serviceChoicePrice: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
(cart tableView) order total cell
class CartTotalTableViewCell: UITableViewCell {
@IBOutlet weak var orderTotal: UILabel!
@IBOutlet weak var OrderTax: UILabel!
@IBOutlet weak var deliveryFee: UILabel!
@IBOutlet weak var grandTotal: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
How do I program the stepper to increase the label in value when selected above is the current code I am using but it crashes upon clicking the stepper, also how do I take this value and either send it to the cart vc to multiply with pricing info in the Options array and send the selected items data to the service choice cell in the cart, or multiply it in the Service1ViewController and send the total data to the cart along with sending the selected items data to the service choice cell?