Reputation: 81
Nutshell - I'm trying to get a highscore out of a plist
Here's the code to read the data:
var myOutput: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("highscore")
println(myOutput!)
This is successful and the result of the println is the correct data
if myOutput != nil{
highscore = myOutput! as Int
}
This gives me a "Swift dynamic cast failure". From everything I've read this should be working, so any tips would be great.
Upvotes: 0
Views: 851
Reputation: 81
Thanks to user2864740 got me on the right track. Correct solution is:
if myOutput != nil{
highscore = myOutput!.integerValue
}
Upvotes: 1