Fast CGFloat for int xcode 6 beta 4

var w:Int  = Int(self.bounds.size.width / Float(worldSize.width))
var h:Int  = Int(self.bounds.size.height / Float(worldSize.height))

      

Error: 'CGFloat does not convert to UInt8'

I researched this type of conversion and I found this Convert Float to Int in Swift my code like this but no idea working?

+3


source to share


1 answer


In beta 4 it CGFloat

became a new type. Thus, you would do:



var w:Int  = Int(self.bounds.size.width / CGFloat(worldSize.width))
var h:Int  = Int(self.bounds.size.height / CGFloat(worldSize.height))

      

+22


source







All Articles