Avoiding sorting in NSDictionary
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 you 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 th开发者_如何转开发e order of how I entered just as in NSArray.
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
精彩评论