是否有方法检测充电器是否在mac计算机上断开连接。
也就是说,是否有可能制作一个应用程序来监听“充电器连接”/“充电器断开”事件?
就像ios一样:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
if ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging) {
NSLog(@"Device is charging.");
}但是我想要一个事件侦听器,例如:-(void) didDisconnectCharger:(id)sender.。
发布于 2013-12-08 11:35:50
我认为您要寻找的函数是IOPSNotificationCreateRunLoopSource in IOKit。
https://stackoverflow.com/questions/20443794
复制相似问题