arc4random - Swift random float between 0 and 1 -
running xcode6-beta4, in public osx yosemite beta.
i'm trying random float between 0 , 1 can't seem type conversions work.
func randomcgfloat() -> cgfloat { return cgfloat(arc4random()) / uint32_max }
i'm getting 'cgfloat' not convertible 'uint8' error
try initializing divisor float well, la:
cgfloat(float(arc4random()) / float(uint32_max))
Comments
Post a Comment