如何查找差价合约

How to do look ups on the CFDictionary

本文关键字:查找 何查找      更新时间:2023-10-16

可能的重复项:
如何从 CFMutableDictionary 中检索特定键的值

在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(值)查找字典。

您可以使用 NSDictionary 并使用 NSNumber 将键装箱(假设您已经创建了一个类来表示您的 stTimer 结构。

[myDictionary setObject: myStTimer forKey: [NSNumber numberWithUnsignedInt: [myStTimer wId]]];
StTimer* mySTTimer = [myDictionary objectForKey: [NSNumber numberWithUnsignedInt: anId]];

我认为使用较低级别的接口没有任何意义。 您不妨坚持使用C++版本。