in swift, how can i detect if this is the first time the app is ran ? i want to create a simple game that sets the high score to 0 if the app is new. if i typed this :
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
NSUserDefaults.standardUserDefaults().setObject(0, forKey: "firstrun")
if ( NSUserDefaults.standardUserDefaults().objectForKey("firstrun")?.integerValue == 0 ){
NSUserDefaults.standardUserDefaults().setObject(0, forKey: "HighScore")
else {
outputLabel.text = String(NSUserDefaults.standardUserDefaults().objectForKey("HighScore")
}
}
This "firstrun" will be reseted to 0 after every launch, how can i solve this issue