I have an NSMutableDictionary with two keys. One for titles (e.g. ‘Test’) and one for distances (e.g. ‘200’ miles).
How can I order these values by the nearest or furthest distance. I would need both the title AND distance value indexes to change when they are ordered.
So this would be the regular version of the NSMutableDictionary:
Titles: (
"Test1"
"Test2"
"Test3"
)
Distances: (
"240"
"43"
"482"
)
And the ordered version (for nearest distances):
Titles: (
"Test2"
"Test1"
"Test3"
)
Distances: (
"43"
"240"
"482"
)
I can’t help but feel that what you want is an NSArray of NSDictionaries, or an NSArray of custom objects. This design feels really awkward and creates extra work — because the only real answer if you structure your data this way is “Create a custom API around the whole thing that very carefully manages this invariant, and then only ever mutate this data structure through that interface.”