I'm having a brain cramp this afternoon. This should be easy.
I did read the docs.
It's easy to convert single instances of Float <> CGFloat but I'm looking for a fast method to cast a LARGE array > 500,000 elements of [Float] to [CGFloat].
var sphereRadiusFloat:[Float] = [0.0,1.0,2.0]
var sphereRadiusCGFloat:[CGFloat] = []
sphereRadiusCGFloat = sphereRadiusFloat as CGFloat
The error is
CGFloat is not convertible to [CGFloat]
I also tried
sphereRadiusCGFloat = CGFloat(sphereRadiusFloat)
which gives error
Could not find an overload operator for 'init' that accepts supplied arguments.
您可以使用map进行以下操作:
sphereRadiusCGFloat = sphereRadiusFloat.map{CGFloat($0)}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.