![]() ![]() The notification's user info dictionary will contain the PDPowerManagementMessage key with an instance is available, call somewhere in your code. with the shared instance of PDPowerManagement as the object. The PDPowerManagementNotification will be sent to the default notification center ![]() Be sure to include the IOKit Framework in your project If you make improvements or additions to the code, please let me know. Of course, I would appreciate a mentioning in your app's about box. Please keep this original notice intact. You may modify and redistribute the code as needed. Originally part of the Journler project: To use Philip's code, just call +sharedPowerManagement to create the singleton manager, then register observers with the notification center to receive PDPowerManagementNotification notifications. (Note: the original web site no longer exists, so I'll just paste it in here.) It would be trivial to rewrite this in Swift, bridge to the Obj-C code, or just use it as an example of using IORegisterForSystemPower and write your own callback functions (if you want exact times). I may have made slight modifications over the years so it compiles for the latest OS and Xcode, but it is otherwise unchanged. This Objective-C wrapper was contributed by Philip Dow over a decade ago and still works fine. ![]() Your callback functions are called when the system wants to go to sleep (you can suggest that it doesn't), is about to go to sleep, and when it wakes up again. You can register callbacks with the system power manager (see IORegisterForSystemPower). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |