iosswiftaccelerate-frameworkswift4.2vdsp

Accelerate framework - vDSP_zvmags - Swift 4.2


In Swift 4.0 Xcode 9.4.1 using the vDSP_zvmags function and passing an inout float array variable works however in Swift 4.2 Xcode 10.1 complains that one cannot pass an array parameter when a expecting a float type.

//Class variable
private var magnitudes: [Float]!    

self.magnitudes = [Float](repeating: 0.0, count: self.halfSize)
vDSP_zvmags(&(self.complexBuffer!), 1, &self.magnitudes!, 1, UInt(self.halfSize))

Error message:

Cannot convert value of type '[Float]' to expected argument type 'Float'

&self.magnitudes! is underlined in red.

Can someone shed some light as to why it is acceptable in Swift 4.0 and not acceptable in Swift 4.2? The function does not appear to have changed between the 2 functions, I have checked in Apple's documentation and looked at the vDSP library doc.


Solution

  • If the class variable is initialized on declaration to empty float array the error disappears.