2

I am trying to create the CICrossPolynomial filter type in Swift.

I am unsure how to create the syntax to do it however.

The documentation specifies a CIVector which has an array of floats?

A CIVector object whose display name is RedCoefficients.

Default value: [1 0 0 0 0 0 0 0 0 0] Identity: [1 0 0 0 0 0 0 0 0 0]

But how do I actually declare such a CIVector? There is one constructor that has this signature

CIVector(values: <UnsafePointer<CGFloat>>, count: <UInt>)

But when I try

var floatArr:Array<CGFloat> = [1,0,0,0,0,0,0,0,0]
var vector = CIVector(values: floatArr, count: floatArr.count)

I get the error:

Cannot invoke 'init' with an argument list type (values: @lvaue Array<CGFloat>, count:Int)

Do you know how I can properly create a CIVector with an array of CGFloats?

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
Aggressor
  • 13,323
  • 24
  • 103
  • 182

1 Answers1

6

floatArr.count has the type Int, but the count: parameter has the type UInt, therefore you need to convert it explicitly:

let floatArr: [CGFloat] = [1,0,0,0,0,0,0,0,0]
var vector = CIVector(values: floatArr, count: UInt(floatArr.count))
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382