Erstelle ein CFRunLoopSourceRef mit IOPSNotificationCreateRunLoopSource in Swift
Ich versuche, Änderungen des Energiezustands unter macOS zu abonnieren. Ich habe herausgefunden, dass es einen Weg gibt, IOKit zu verwenden, obwohl es etwas verworren ist. Ich muss es mit @ importier#import <IOKit/ps/IOPowerSources.h>
in einem ObjC Bridging-Header. Dann erhalte ich Zugriff auf die Funktion IOPSNotificationCreateRunLoopSource, die die Signatur hat:
IOPSNotificationCreateRunLoopSource(_ callback: IOPowerSourceCallbackType!, _ context: UnsafeMutablePointer<Void>!) -> Unmanaged<CFRunLoopSource>!
Ich habe Hilfe von der Antwort in Callback-Methode für Apple-Run-Loop, schafft es aber immer noch nicht, eine Funktion vom Typ @ zu erstellIOPowerSourceCallbackType
in Swift. Was fehlt, um diese Kompilierung zu haben?