在我的代码中,我使用JSONValue来获取NSDictionary。
字典看起来像这样:
{
{ID = 0, NAME = "Patrick"},
{ID = 1, NAME = "Ted"},
{ID = 2, NAME = "John"},
{ID = 3, NAME = "Allen"},
{ID = 4, NAME = "David"}
}
我想在以下委托函数中返回相应ID的名称:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
最有效的方法是什么?
答案 0 :(得分:0)
例如:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
// Assuming that you have just one component
return [jsonDict[row] objectForKey: @(row) ];
}