1

There is still an issue with defining callbacks in CoreMIDI with Swift, so the workaround is to use Objective-C. I found this answer, but I cannot figure out how to use MIDIReadProcCallback.setOnCallback({ (packetList: MIDIPacketList) in ... }) from this answer: https://stackoverflow.com/a/26139259/616873.

I cannot comment on the specific answer for more clarification because my rep is not 50, so if anyone can point me to some sample code or further clarification, I would be very appreciative.

Community
  • 1
  • 1
Jess
  • 85
  • 2
  • 9
  • The answer is correct, so what problem are you having? Just do what the answer tells you to do. – matt May 28 '15 at 15:56

1 Answers1

2

Here is a blog post and github repo with a working example. The Swift code uses objc as a trampoline for the function pointers.

Gene De Lisa
  • 3,628
  • 1
  • 21
  • 36
  • 1
    Thanks so much, I actually have been watching your blog in hopes for a workaround! Nice solution for the lack of the next packet function.(I would give you rep, but I'm below the minimum to do that.) – Jess Jun 04 '15 at 23:46
  • And I thought only my cat read my blog :) I used one of my developer support questions to Apple on this. They responded that yeah, callbacks don't work in Swift, so keep the trampoline. Sigh. Glad it helped you. – Gene De Lisa Jun 05 '15 at 00:04