so recently I started learning swift and for practicing I wanted to do an homework counter app, It‘s an app that every time you press a button it add to the variable counting 1.
The problem is every time I close the app and open it, the count is reset.
How can I make the variable counting keep its count even if the app is closed?
Here is my code :
import UIKit
var counting = 0
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBAction func button(_ sender: Any) {
counting += 1
label.text = "You did \(counting) homeworks"
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
Can someone help please?