basically I have an NSDictionary with keys and values.
The keys are all numbers, but at the moment they are strings.
I want to be able to compare them as numbers
You can't sort a dictionary, but you can get the keys as an array, sort that, then output in that order. sortedArrayUsingComparator will do that, and you can compare the strings with the NSNumericSearch option.
NSArray* keys = [myDict allKeys];
NSArray* sortedArray = [keys sortedArrayUsingComparator:^(id a, id b) {
return [a compare:b options:NSNumericSearch];
}];
for( NSString* aStr in sortedArray ) {
NSLog( @"%@ has key %@", [myDict objectForKey:aStr], aStr );
}