nsnumber - NSObject to Int (Swift) -


is possible convert nsobject int? , how can implement this? i've apple reference guide can't seem understand how use intvalue under nsobject reference.

var intvalue: int32 { } 

i receive nsobject class highestscore saved. want compare highestscore current score , if current score larger highestscore send current score saved. have except i'm not able compare nsobject (highest score) int (current score)

here how retrieve highestscore:

 func retrivehighscore() -> nsobject {     var datatoretrive = highscore()     documentdirectories = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)     documentdirectory = documentdirectories.objectatindex(0) string     path = documentdirectory.stringbyappendingpathcomponent("highscore.archive")     if let datatoretrive2 = nskeyedunarchiver.unarchiveobjectwithfile(path) as? highscore {         datatoretrive = datatoretrive2     }      return(datatoretrive) } 

and here how in class calling savehighscore class , retrievehighscore function:

var bestscore = savehighscore.retrivehighscore 

how can compare , int value bestscore variable nsobject

thanks help

if object 'real' anyobject, 1 knows represents sequence of digits representing int number, following code works me (xcode version 6.1 (6a1052c)):

 let oint = (object string).toint() // in app object has type _ttsq ,   var intresult = 0  if oint != nil { intresult = oint! }  // intresult has type _ttsi 

i tried make simpler snippet above 1 works


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -