Detecting device arrival and departure

Has anyone else been successful at getting device notifications on the MacOS using JUCE? I’ve copied in the code from Apple:

which compiles, but I never get a notification of arrival or depature of a device.

The one thing I can’t do is call CFRunLoopRun() at the end. I assume that at some low level the JUCE application classes are calling something that starts the RunLoop. Does it suffice to CFRunLoopAddSource() with the new events to listen for without calling CFRunLoopRun()?

I think that you just need to add it to the current run loop. I was adding a Mac menu to a little JUCE test app and I didn’t need to make my own run loop to service the menu events - the event dispatcher just did the right thing.

I haven’t tried it myself for this case, but I suspect it works the same.

It turns out there’s no problem with the CFRunLoop. It’s already
going and doesn’t need to be run again.

My problem was in the callbacks. I had written them so they didn’t clear the iterators on their initial run, so the callbacks weren’t “armed”