@Claude31 I can't use class type as this Data instance is provided to me by the OS whenever my Completion is been called w.r.t Receive.
Now I want to use this data instance in C++. For which basically I create a wrapper class over this and pass it as Opaque to C++.
Code Snippet
class DataHolder {
init () {}
public var data_wrapper : Data?
}
func ReceiveHandler (_ pContent : Data? ) -> UnsafeMutablePointer {
// pContent is only valid inside scope of this function .
// Create a instance of wrapper class
var x = DataHolder.init ()
// Copy being created here.
x.data_wrapper = pContent
return Unmanaged.passRetained (x).toOpaque ()
}
Problem is copy creation each time which i want to prevent.