Expected declaration error for making high score [duplicate]

You are getting this error because you have the code in the wrong place in the class so move it to any function or in viewDidLoad method.

You can have only declarations in class scope, not expressions to be executed.

And it will work fine.

EDIT:
In your second UIViewController just read highScore from NSUserDefaults this way:

let hScore = NSUserDefaults.standardUserDefaults().objectForKey("Highscore") as! String
highSchoreLabel.text = hScore

Leave a Comment