I want to convert a Float
to an Int
in Swift. Basic casting like this does not work because these types are not primitives, unlike float
s and int
s in Objective-C
var float: Float = 2.2
var integer: Int = float as Float
But this produces the following error message:
'Float' is not convertible to 'Int'
Any idea how to property convert from Float
to Int
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…