this code:
var array = [(0.0, 0.0, 0.0, 0.0)]
xcode thinks double array. should cgfloat array. tried
var array: cgfloat = [(0.0, 0.0, 0.0, 0.0)] var array = [(0.0, 0.0, 0.0, 0.0)] as! cgfloat var array: [cgfloat] = [(0.0, 0.0, 0.0, 0.0)]
and other options without success. how let xcode know cgfloat array? can not append values array now.
actually, there points should consider:
var array = [(0.0, 0.0, 0.0, 0.0)]
not array of doubles, array of tuples contain 4 doubles, i.e if tried cmd , click @array
, see data type as:[(double, double, double, double)]
.
adapted swift documentation:
tuples group multiple values single compound value. values within tuple can of type , not have of same type each other.
if pretty sure making array of tuples, cannot let array of tuples of cgfloats, should be:
var array: [(cgfloat, cgfloat, cgfloat, cgfloat)] = [(0.0, 0.0, 0.0, 0.0)]
its data type
[(cgfloat, cgfloat, cgfloat, cgfloat)]
.if purpose let array of cgfloats, there no need add
()
when declaring it:let array: [cgfloat] = [0.0, 0.0, 0.0, 0.0]
note when assigning floating-point number variable, should of type
double
, have give desired data type (which in case[cgfloat]
).
hope helped.
Comments
Post a Comment