How to create a JSON from an NSDictionary keeping the order of the elements you added?
You know, we actually ran into an issue with that kind of thing a few months back. But we did not find a solution this elegant:
Use an OrderedDictionary!
“A what?” you say? Why, that’s from this Cocoa With Love post from a couple years back:
The default Cocoa collection classes are highly capable but there are situations where you may need to override them to alter their functionality. I’ll explain when and how you should do this with an example class: OrderedDictionary (an NSMutableDictionary subclass that maintains ordering of its keys)…
Interesting tips there even if you don’t actually have any immediate use for an ordered dictionary!