Getting Numbers From A CFDictionary For Use In Calculations, iPhone

旧街凉风 提交于 2019-12-23 05:36:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!