Reputation: 14317
I saw some post to use this Ordered Dictionary solution in order to keep NSDictionary ordred.
It saves it in the same order that I get it from json object, but since I need to use the values for a UIPickerView, I wrote the following:
OrderedDictionary *countryStates = [businessInfo objectForKey:@"allowedStates"];
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
NSString *stateShort = [countryStates keyAtIndex:row ];
return [countryStates objectForKey:stateShort];
}
However, I get:
[__NSCFDictionary keyAtIndex:]: unrecognized selector sent to instance
Upvotes: 0
Views: 89
Reputation: 3172
You get this error because the object associated to the @"allowedStates"
in businessInfo
is only a NSDictionay
. You should use OrderedDictionary
's + (id)dictionaryWithDictionary:(NSDictionary *)dict
method to create a new object and then manipulate it.
Upvotes: 2