How can use CGFloat in Swift?

Aeli.li picture Aeli.li · Jun 3, 2014 · Viewed 33k times · Source
var posinonY:Float = Float(y) + Float(pipeDown.size.height) + Float(verticalPipeGap)
pipeDown.position = CGPointMake(0.0, Float(posinonY))

I get this error:

"NSNumber' is not a subtype of 'CGFloat'"

Why?


Edit:

CGFLoat need double type

pipeDown.position = CGPointMake(0.0,  Double(posinonY))

this is ok.

Answer

MJN picture MJN · Jun 3, 2014

Use CGFloat(number) instead of Float(number)

pipeDown.position = CGPointMake(0.0, CGFloat(posinonY))