Are keys and values in an NSDictionary ordered?

No, they are not ordered. As long as you don’t add or remove any elements from the dictionary, they will remain in the same order, but as soon as you add or remove an element, the new order will be completely different.

If you need the keys/values to be ordered, use an NSArray (or some other ordered data structure) instead.

Leave a Comment