Within Swift 3, I need to send data to a C object accepting float **
input.
In Swift 2, I used to declare a UnsafeMutablePointer< UnsafeMutablePointer<Float32>>
, construct a swift Array (only for init!), and pass this to the pointer, and it worked:
var bufferOut: UnsafeMutablePointer< UnsafeMutablePointer<Float32>>?
arrayOut = Array(repeating: Array(repeating: 0, count: Int(size1), count: Int(size2))
bufferOut = UnsafeMutablePointer< UnsafeMutablePointer<Float32>>(arrayOut)
This is all broken now in Swift 3!
- What is the most Swifty way to pass a C-Style
float**
and initialize it? - What would be the best way to assign values in a
UnsafeMutablePointer< UnsafeMutablePointer<T>>
?
Documentations say that for T **
one should use AutoreleasingUnsafeMutablePointer<T>
but I actually never managed to construct one!
Note that I don't actually care for the Array in the above example! If I could just initialize the Pointer directly using known capacities, I would.
Note: The Expected use cases Section of UnsafeRawPointer describes useful situations such C array and C Buffers, however translating such methods for the above construct is not evident!