In Swift 3, I need to send data to a C object that accepts the input float ** .
In Swift 2, I used the declaration UnsafeMutablePointer< UnsafeMutablePointer<Float32>> , built a fast array (only for init!) And passed it 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)
In Swift 3, it's all broken!
- What is the most Swifty way to pass C-Style
float** and initialize it? - What would be the best way to assign values ββto
UnsafeMutablePointer< UnsafeMutablePointer<T>> ?
The docs say that for T ** should use AutoreleasingUnsafeMutablePointer<T> , but I never managed to create one!
Please note that I really don't care about the array in the above example! If I could just initialize the pointer directly using the known features, I would do it.
Note : Expected Use Cases The UnsafeRawPointer section describes useful situations, such as C-array and C-buffers, however, translation of such methods for the above construction is not obvious!
source share