DEV Community

Kiwi
Kiwi

Posted on

Help ;-;

import UIKit

class ItemTableViewCell: UITableViewCell {

@IBOutlet weak var stepperText: UILabel!

@IBOutlet weak var priceLabel: UILabel!

var item : Item! // this is a view controller class that have the item data .. price as a double (var price: Double! )


override func awakeFromNib() {

    super.awakeFromNib()

}


IBAction func stepper(_ sender: UIStepper) {

    var item : Item! // I called it again bc it didn’t connect in the stepper func ;-;

    stepperText.text = String(Int(sender.value))

    priceLabel.text = String(Int(sender.value))

    let n = item.price // HERE is the error (Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value)

    let nn = Double(Double(stepperText.text! ?? “0”) ?? 0)

    priceLabel.text = “\(n! * nn )”

    // i made this code to take the item price and when I use the stepper it multiple the step number with the price ;0; help plz
}
Enter fullscreen mode Exit fullscreen mode

}

Top comments (0)