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

}

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay