从计算中使用CFDictionary获取数字,iPhone [英] Getting Numbers From A CFDictionary For Use In Calculations, iPhone

查看:215
本文介绍了从计算中使用CFDictionary获取数字,iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在旅行中发现了这一点:

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"

#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?

非常感谢,

Stuart

推荐答案

一旦知道实际字典存储这些值的位置,您可以使用以下内容从字典中访问该值调用:

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
);

进一步检查目录 http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/ 将可能允许您找出要调用哪些对象/方法来获取字典,并且类中的文档说明它指向的内容(在您之前提到的两个键中,它们指向CFNumbers,因此在这种情况下,CFDictionaryGetValue将返回一个CFNumber 。

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.

这篇关于从计算中使用CFDictionary获取数字,iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆