在 Swift 4.0 Xcode 9.4.1 中使用 vDSP_zvmags 函数并传递一个 inout float 数组变量是有效的,但是在 Swift 4.2 Xcode 10.1 中提示当期望一个 float 类型时不能传递数组参数。
//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))
错误信息:
Cannot convert value of type '[Float]' to expected argument type 'Float'
&self.星等!带有红色下划线。
有人可以阐明为什么它在 Swift 4.0 中可以接受而在 Swift 4.2 中 Not Acceptable 吗?这两个函数之间的函数似乎没有变化,我查看了 Apple 的文档并查看了 vDSP 库文档。
最佳答案
如果类变量在声明时初始化为空 float 组,则错误消失。
关于ios - 加速框架 - vDSP_zvmags - Swift 4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53220789/