0

i am creating an app for Know the quantity of liquid I have and I need to storage a number whose in a label, with this label who are connected to a steeper.

I try to UserDefaults.standard.set(mintLabel, forKey: "podsM") but Xcode say that Cannot invoke 'set' with an argument list of type '(UILabel?, forKey: Int)

@IBOutlet weak var mintLabel: UILabel!
@IBOutlet weak var cremeLabel: UILabel!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    print(UserDefaults.standard.dictionaryRepresentation())

}

@IBAction func mintStepper(_ sender: UIStepper) {
  mintLabel.text = String(Int(sender.value))
    UserDefaults.standard.set(mintLabel, forKey: "podsM")

}

1 Answers1

0

You're passing the UILabel to the set method, not the value itself, which is causing the error. Try this instead:

let value = Int(sender.value)
mintLabel.text = String(value)
UserDefaults.standard.set(value, forKey: "podsM")
rob
  • 99
  • 1
  • 3