0

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

  `UnsafeMutablePointer<UnsafeMutablePointer<Float>?>! `

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

UnsafePointer<UnsafeMutablePointer<Float>>?

我无法在两者之间进行投射。我试图通过执行以下操作使其可变:

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

那没有用。Swift 指针类型之间的转换非常令人沮丧。任何帮助将不胜感激。

谢谢

4

1 回答 1

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

testPtr = unsafeBitCast( testPtr2, to: UnsafeMutablePointer<UnsafeMutablePointer<Float>?>!.self)
于 2018-03-20T13:49:35.500 回答