views:

45

answers:

1

I was using NSDictionary and i observed that the objects in the dictionary are sorted automatically with respect to the keys, so my question is how to avoid this sorting , any flag available to set it off, so i get the object in same order i entered.

i know u may be thinking what difference it makes in dictionary since we retrieve the value with respect to key, but i am first getting allKeys from which i receive Array of keys , this order is what i need it to be in the order of how i entered just as in NSArray.

give your comments if the question is not clear.

Thanks

+1  A: 

I guess that there will not be a method to control the sorting in NSDictionary, because 'NSDictionary' is a hash table which uses hash function to chose the place to store the values(for speedy accessing).

To customize dictionary you can use CFDictionaryRef there you can write your custom callback. You can write your own CFDictionaryHashCallBack function to compute the place for storing. CFDictionary is "toll-free bridged" with NSDictionary.

Regards
Devara Gudda

Devara Gudda
Thnaks Devara Gudda
RVN