Possible Duplicate:
NSDictionary with ordered keys
Im using XMPPFramework for iOS, and Im quite suprised seing that a NSDictionary containing the occupants of a room changes the order of its content every time a new occupant/element is inserted.
Here's the output, after each insert.
<CFBasicHash 0xbccbd60 [0x1f02400]>{type = mutable dict, count = 2,entries =>
1 : <CFString 0xbcd90b0 [0x1f02400]>{contents = "4ee90610e4b08c62894a648c"} = <XMPPRoomOccupant: 0xbcd9360>
2 : <CFString 0xbe5a160 [0x1f02400]>{contents = "4eea53a6e4b08c62894a6c90"} = <XMPPRoomOccupant: 0xbca7cc0>
}
<CFBasicHash 0xbccbd60 [0x1f02400]>{type = mutable dict, count = 3,entries =>
0 : <CFString 0xbe60710 [0x1f02400]>{contents = "4ee8fca3e4b08c62894a6489"} = <XMPPRoomOccupant: 0xbe61370>
1 : <CFString 0xbcd90b0 [0x1f02400]>{contents = "4ee90610e4b08c62894a648c"} = <XMPPRoomOccupant: 0xbcd9360>
2 : <CFString 0xbe5a160 [0x1f02400]>{contents = "4eea53a6e4b08c62894a6c90"} = <XMPPRoomOccupant: 0xbca7cc0>
}
<CFBasicHash 0xbccbd60 [0x1f02400]>{type = mutable dict, count = 4,entries =>
0 : <CFString 0xbe5a160 [0x1f02400]>{contents = "4eea53a6e4b08c62894a6c90"} = <XMPPRoomOccupant: 0xbca7cc0>
4 : <CFString 0xbe71eb0 [0x1f02400]>{contents = "4f7ade44e4b09cb64dc33b90"} = <XMPPRoomOccupant: 0xbe72950>
5 : <CFString 0xbe60710 [0x1f02400]>{contents = "4ee8fca3e4b08c62894a6489"} = <XMPPRoomOccupant: 0xbe61370>
6 : <CFString 0xbcd90b0 [0x1f02400]>{contents = "4ee90610e4b08c62894a648c"} = <XMPPRoomOccupant: 0xbcd9360>
}
AS you can see in this last insert it changed the order of 2 elements, it changed its index too. Is this normal? I looked at the code and its inserting using:
[occupants setObject:occupant forKey:aNickName];
I need the elements to be stored in the order it was inserted. And I also need to access the element through a string. Any idea?
Thanks