如何投射UnsafePointer <unsafemutablepointer <float>&gt;?到UnsafeMutablePointer <unsafemutablepointer <float>?&gt;!

时间:2018-03-12 07:33:51

标签: ios unsafemutablepointer

我有一个需要在Swift中进行交互的C API。 其中一个函数将一个指针数组作为参数,由Swift导入为

  `UnsafeMutablePointer<UnsafeMutablePointer<Float>?>! `

Swift端的相应输入是AVAudioPCMBuffer.floatChannelData,定义为

UnsafePointer<UnsafeMutablePointer<Float>>?

我在两者之间施展有困难。 我尝试通过以下方式使其变得可变:

UnsafeMutablePointer<UnsafeMutablePointer<Float>>(AVAudioPCMBuffer.floatChannelData)

这不起作用。 Swift指针类型之间的转换非常令人沮丧。任何帮助都将非常感激。

由于

1 个答案:

答案 0 :(得分:0)

var testPtr : UnsafeMutablePointer<UnsafeMutablePointer<Float>?>! = nil
var testPtr2 : UnsafePointer<UnsafeMutablePointer<Float>>? = nil

testPtr = unsafeBitCast( testPtr2, to: UnsafeMutablePointer<UnsafeMutablePointer<Float>?>!.self)