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
Post a Comment