Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift CGFloat to int xcode 6 beta 4

Tags:

xcode

swift

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

Error : 'CGFloat is not convertible to UInt8'

I researched this conver type and i found this one Convert Float to Int in Swift my code like this but not working any idea ?

like image 999
Gökhan Çokkeçeci Avatar asked Aug 05 '14 11:08

Gökhan Çokkeçeci


1 Answers

In beta 4, CGFloat has become a new type. So you'd do:

var w:Int  = Int(self.bounds.size.width / CGFloat(worldSize.width))
var h:Int  = Int(self.bounds.size.height / CGFloat(worldSize.height))
like image 61
DarkDust Avatar answered Oct 17 '22 21:10

DarkDust