Use it like this:
NSArray *arrangedValues = [myDictionary arrangedValuesWithArrangedKeys:myOrderedArrayOfKeys];
Here's the category:
@interface NSDictionary (Ordering)
- (NSArray *)arrangedValuesWithArrangedKeys:(NSArray *)orderedKeys;
@end
@implementation NSDictionary (Ordering)
- (NSArray *)arrangedValuesWithArrangedKeys:(NSArray *)orderedKeys
{
NSMutableArray *orderedArrayOfValues = [[[NSMutableArray alloc] init] autorelease];
for (id key in orderedKeys) {
[orderedArrayOfValues addObject:[self objectForKey:key]];
}
return [NSArray arrayWithArray:orderedArrayOfValues];
}
@end