Is it possible to convert a NSObject to an Int? and how can I implement this? I've look the Apple Reference Guide but I can't seem to understand how to use intValue under NSObject reference.
var intValue: Int32 { get }
I receive a NSObject from another class that is the HighestScore saved. I want to compare this HighestScore with the current Score and if current score is larger than highestScore send the current score to be saved. I have all that already except I'm not able to compare the NSObject (highest score) with my Int (current score)
Here is how I retrieve the HighestScore:
func RetriveHighScore() -> NSObject {
var dataToRetrive = HighScore()
documentDirectories = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
documentDirectory = documentDirectories.objectAtIndex(0) as String
path = documentDirectory.stringByAppendingPathComponent("highScore.archive")
if let dataToRetrive2 = NSKeyedUnarchiver.unarchiveObjectWithFile(path) as? HighScore {
dataToRetrive = dataToRetrive2
}
return(dataToRetrive)
}
And here is how in another class I am calling the SaveHighScore class and the RetrieveHighScore function:
var bestScore = SaveHighScore.RetriveHighScore
How can I compare and Int value to my bestScore variable that is an NSObject
Thanks for your help