I got NSDictionary with pairs like :
Key -> Value:
@\"home\" -> @\"blue\"
@\"family\" -> @\"green\"
@\"work\" -> @\"red\"
You can't sort an NSDictionary. If you want , you could create an object to hold the key and value in it, then add to an array and use a sort descriptor to sort on the key field.
NSDictionary is not an ordered collection, however you can sort its keys using comparators like keysSortedByValueUsingComparator, keysSortedByValueUsingSelector.
You can access the keys in a sorted order with method like keysSortedByValueUsingComparator
, keysSortedByValueWithOptions
or keysSortedByValueUsingSelector
. But by definition a NSDictionary
itself has no notion or order.