问题
I'm trying to find a SDK or anything in Cocoa for OS X that will detect when an iPhone is connected and will show the battery percentage of the iPhone just like iTunes where it shows you how much your phone is charged (the little battery icon). So if anyone can tell me if there is something like this i thank you in advance. (BTW this has to be for OS X)
回答1:
Have a look at https://bitbucket.org/tristero/mobiledeviceaccess Specifically, getMobileGestaltValue: using the key BatteryCurrentCapacity That will give you the numeric value you want - displaying it is a different issue.
https://bitbucket.org/tristero/ipodaccessframework is a skeleton application that shows how to monitor for iDevices being connected...
In fact, https://bitbucket.org/tristero/ipodbattery is exactly what you want.
来源:https://stackoverflow.com/questions/27805987/iphone-battery-percentage-on-os-x-cocoa-like-itunes