iPhone Battery Percentage on OS X (Cocoa) like iTu

2019-08-05 18:13发布

问题:

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.