如何在 CFDictionary 上进行查找
在 C++ 中:
typedef struct
{
unsigned short wId;
bool bPersists;
unsigned short uPeriod;
bool bStop;
}stTimer;
unsigned short wId;
stTimer pEvent;
CTypedPtrMap<CMapWordToPtr,WORD,stTimer*>m_cIdMap;
if(m_cIdMap.Lookup(wId,pEvent))
{
//find and remove the event pEvent;
}
我需要将相同的功能移植到 Objective-C
我可以将值设置并获取到 CFDictionary
中,但我需要看看使用 wId
(键)和 pEvent
(值)将 ups 放入字典中。
Possible Duplicate:
How to retrieve the values for the particular key from CFMutableDictionary
In C++:
typedef struct
{
unsigned short wId;
bool bPersists;
unsigned short uPeriod;
bool bStop;
}stTimer;
unsigned short wId;
stTimer pEvent;
CTypedPtrMap<CMapWordToPtr,WORD,stTimer*>m_cIdMap;
if(m_cIdMap.Lookup(wId,pEvent))
{
//find and remove the event pEvent;
}
I need to port the same functionality to Objective-C
I could be able to set and get the values into the CFDictionary
, but I need to do look ups into the dictionary with the wId
(key) and the pEvent
(value).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将使用 NSDictionary 并用 NSNumber 将键装箱(假设您已经创建了一个类来表示您的 stTimer 结构)。
我认为没有任何必要使用较低级别的接口。您最好坚持使用 C++ 版本。
You would use an NSDictionary and box the keys with NSNumber (assuming you have created a class to represent your stTimer struct.
I don't see any point of going for a lower level interface. You might as well stick with the C++ version.