casting - Convert Float to Int in Swift -


i want convert float int in swift. basic casting not work because these types not primitives, unlike floats , ints in objective-c

var float: float = 2.2 var integer: int = float float 

but produces following error message:

'float' not convertible 'int'

any idea how property convert float int?

you can convert float int in swift this:

var myintvalue:int = int(myfloatvalue) println "my value \(myintvalue)" 

you can achieve result @paulm's comment:

var myintvalue = int(myfloatvalue) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -