0

NSDictionary の順序を維持するために、この Ordered Dictionaryソリューションを使用する投稿を見ました。

json オブジェクトから取得したのと同じ順序で保存しますが、UIPickerView の値を使用する必要があるため、次のように記述しました。

 OrderedDictionary *countryStates = [businessInfo objectForKey:@"allowedStates"];

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
        NSString *stateShort = [countryStates keyAtIndex:row ];
        return [countryStates objectForKey:stateShort];
}

しかし、私は得る:

[__NSCFDictionary keyAtIndex:]: unrecognized selector sent to instance 
  1. なぜ私はそれを得るのですか?
  2. 注文を台無しにすることなく、UIPickerView の注文済み辞書を使用できる他の方法はありますか?
4

1 に答える 1

2

@"allowedStates"in に関連付けられているオブジェクトbusinessInfoNSDictionay. OrderedDictionaryのメソッドを使用+ (id)dictionaryWithDictionary:(NSDictionary *)dictして新しいオブジェクトを作成し、それを操作する必要があります。

于 2013-07-14T18:51:07.690 に答える