The IOKit
framework is Apple’s base framework to interact with devices.
This is your go to when for instance working with USB devices.
There is a way in IOKit to register notifications to discover devices as they are plugged by our users. The API seems easy enough (see IOKitLib header)
However I was puzzled for quite long why my notifications were not processed.
It turns out you have to process the iterator immediately after calling
IOServiceAddMatchingNotification
, otherwise notifications won’t be