I am new to Objective-C and iPhone
I have to sort a NSDictionary using values and according to that i have to arrange the keys of that values, i have sorted the array.
//getting values
NSArray* keys1 = [sortDictionary allValues];
NSArray* sortedArray = [keys1 sortedArrayUsingComparator:^(id a, id b) {
return [a compare:b options:NSNumericSearch];
}];
My problem now is I am getting the keys of the values by allKeysForObject: , which returns an NSArray.
for( NSString* aStr in sortedArray ) {
NSLog( @"%@ has value %@", [sortDictionary allKeysForObject:aStr], aStr );
}
O/P :- ( Sourish ) has value 60
Rather i want “Sourish” as a string and store it to a NSArray and than store that NSArray to NSDictionary or store both Sourish and 60 to another NSDictionary
Kindly make me to sort our this problem.
This gets the string for you by looking at the array. Is that what you are after?
This logs: