Reputation: 984
The apple documentation gives the declaration of SCNVector3 :
typedef struct SCNVector3 { CGFloat x, y , z; } SCNVector3;
Or when trying to write an overload function :
func * (left: SCNVector3, right: CGFloat) -> SCNVector3 {
return SCNVector3Make(left.x * right, left.y * right, left.z * right)
}
I get the "cannot invoke '' with an argument list of type" error. Aren't left.x, left.y and left.z supposed to be CGfloat ?
How and when is it decided if CGFloat will be a double or a float?
Upvotes: 3
Views: 1440
Reputation: 539745
In the iOS 8.1 SDK headers, the SCNVectorX
types are based on Float
, as can be seen
by command-clicking on SCNVector3
:
struct SCNVector3 {
var x: Float
var y: Float
var z: Float
}
func SCNVector3Make(x: Float, y: Float, z: Float) -> SCNVector3
This is different from the OS X 10.10 SDK where CGFloat
is used. So the documentation
seems to be wrong. The following compiles in an iOS project:
func * (left: SCNVector3, right: Float) -> SCNVector3 {
return SCNVector3Make(left.x * right, left.y * right, left.z * right)
}
Upvotes: 2