NSData* myData = [NSData dataWithBytes:&pEvent length:sizeof(pEvent)];
wTimerId = 99;
[m_cAppIdMap setObject:myData forKey:[NSNumber numberWithUnsignedShort:wTimerId]];
wTimerId = 96;
[m_cAppIdMap setObject:myData forKey:[NSNumber numberWithUnsignedShort:wTimerId]];
wTimerId = 97;
[m_cAppIdMap setObject:myData forKey:[NSNumber numberWithUnsignedShort:wTimerId]];
wTimerId = 98;
[m_cAppIdMap setObject:myData forKey:[NSNumber numberWithUnsignedShort:wTimerId]];
wTimerId = 95;
[m_cAppIdMap setObject:myData forKey:[NSNumber numberWithUnsignedShort:wTimerId]];
我使用键值99,96,97,98,95存储数据。但它存储为
{
98 = <b0c71000 01000000>;
97 = <b0c71000 01000000>;
96 = <b0c71000 01000000>;
99 = <b0c71000 01000000>;
95 = <b0c71000 01000000>;
}
为什么会这样。有没有办法以先存储的方式排列字典。
答案 0 :(得分:3)
词典本质上是无序的。如果您想订购,请使用数组。
如果您想同时进行基于订单和基于密钥的查找,请同时存储数组和字典;一个保存顺序,另一个保存基于密钥的查找。
让他们保持同步。