I am using xcode 8 swift 3. I have a mini App where I time myself how long I can answer the given questions, I have made it pass my time to the next VC and actually save it. I am wondering how do I save all the times I get in the App.
Button to save score
@IBAction func saveScore(_ sender: Any) {
label.text = label.text
UserDefaults.standard.set(label.text, forKey: "score")
}
User Defaults part
override func viewDidAppear(_ animated: Bool) {
if let x = UserDefaults.standard.object(forKey: "score") as? String {
label.text = x
}
}