问题
I found this in my travels:
http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/IOPSKeys.h
How would I get the values (as a number) of:
#define kIOPSMaxCapacityKey "Max Capacity"
and
#define kIOPSDesignCapacityKey "DesignCapacity"
I want to be able to use them throughout my app. What do I need to add to my project and how do extract the numbers?
Many thanks,
Stuart
回答1:
Once you know where the actual dictionary is that it's storing these values, you can access the value from the dictionary using the following call:
CFDictionaryGetValue (
CFDictionaryRef theDict,
const void *key
);
Further examination of the directory http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/ would probably allow you to figure out which objects/methods to call to get the dictionary, and the documentation within the class states what it points to (in your two previously mentioned keys, they point to CFNumbers, so in that case CFDictionaryGetValue will return a CFNumber.
来源:https://stackoverflow.com/questions/2225019/getting-numbers-from-a-cfdictionary-for-use-in-calculations-iphone