我有这个功能
func arrayForPointer<T>(_ pointer: UnsafePointer<T>, count: Int) -> [T] {
let buffer = UnsafeBufferPointer<T>(start: pointer, count: count)
return Array(buffer)
}
这个电话
let arrayComplex = self.arrayForPointer(&output, count: 4)
我想通过枚举arrayComplex
并将实部提取到常规数组中,例如
var arrayReal: [Float] = []
for item in arrayComplex {
let myFloat = item.realp \\ get the real part of item
arrayReal.append(myFloat)
}
线
let myFloat = item.realp \\ get the real part of item
是不正确的。
item
是一个UnsafeMutablePointer<Float>
看在上帝的份上,我该怎么做?
谢谢。
========================
这是output
var A = [Float](repeating:0, count:samples/2);
var B = [Float](repeating:0, count:samples/2)
var output = DSPSplitComplex(realp: &A, imagp: &B)