How to add a callback method to Apple event listener like:
CFRunLoopSourceRef IOPSNotificationCreateRunLoopSource(IOPowerSourceCallbackType callback,
void *context);
How do i add a method or block to the following method so that when the power source changes I can log something like below, (I can see that it is C++ but NSLog still works in Obj-C++) something like:
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
CFRunLoopSourceRef IOPSNotificationCreateRunLoopSource(callbackMethod(),
void *context);
}
void callbackMethod(){
// NSLog("No power connected"); or NSLog("Power connected");
}
I guess i need to change :
IOPowerSourceCallbackType callback
to a pointer or something?