Configuring MIDiSysexSendRequest (Data types)

I would like to send a MIDISysex using the CoreMIDI API. I do not know how to fill out the last two data types in the struct, prompting errors in Xcode.
The struct:
Code Block
struct MIDISysexSendRequest{
MIDIEndpointRef destination;
const Byte * data;
UInt32 bytesToSend;
Boolean complete;
Byte reserved[3];
MIDICompletionProc completionProc;
void * completionRefCon;};

Both the completionProc and the completionRefCon have to be initialized to something. Does anybody know what?

As an example,
Code Block
var completionProc = MIDICompletionProc()

brings the error: Non-nominal type 'MIDICompletionProc' does not support explicit initialization.

EDIT: the MIDICompletionProc can be filled by defining a function, e.g.
Code Block
func MIDICompletionProc(request: UnsafeMutablePointer<MIDISysexSendRequest>) -> Void { }

Which leaves how to initialize the completionRefCon.


MIDICompletionProc is a typealias of a closure type, as shown in the doc.

Code Block
typealias MIDICompletionProc = (UnsafeMutablePointer<MIDISysexSendRequest>) -> Void
You may need to pass a global function or a closure of @convention(c).

completionRefCon is any type of pointer which points to some stable address while MIDI process is running.
Or it can be nil.

So, for example, you can write something like this:
Code Block
// Define a global function, somewhere outside any classes
func handleMIDISysexSendRequestCompletion(_ request: UnsafeMutablePointer<MIDISysexSendRequest>) {
//...
}
class SomeClass {
//...
func someFunc(...) {
//...
var request = MIDISysexSendRequest(
destination: endPoint,
data: dataPointer,
bytesToSend: dataSize,
complete: isComplete,
reserved: (0,0,0),
completionProc: handleMIDISysexSendRequestCompletion,
completionRefCon: nil
)
let result = MIDISendSysex(&request)
print(result)
//...
}
}


Configuring MIDiSysexSendRequest (Data types)
 
 
Q