Had the same problem some time ago when writing a similar app that receives MIDI input and logs it to the console.
Am assuming you are working with ARC.
Have solved the problem as follows:
First, I did the following cast (that would be in your awakeFromNib method, whereas &test would be some_object):
SomeClass *some_object = [[SomeClass alloc] init];
MIDIInputPortCreate(midiClient, CFSTR("Input"), midiInputCallback, (__bridge_retained void *)some_object, &inputPort);
Then, inside midiInputCallback, I have casted it back with:
SomeClass *some_object = (__bridge SomeClass*)procRef;
Hope I don't have any typos here, just did a quick copy and paste with some modifications for the context of this answer.
Checkout the following question and its answers, helped me a lot understanding it: