Given this dictionary:
"vals":[
{
"ID":"1",
"NAME":"Jack"
},
{
"ID":"2",
"NAME":"Jason"
},
{
"ID":"3",
"NAME":"Sheryl"
},
{
"ID":"4",
"NAME":"Clark"
},
{
"ID":"5",
"NAME":"Markus"
}]
I am using pickerView’s method:
NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
So, given the NSInteger row, how do I get the name of that ID?
very basic way:
although you should probably remember that the pickerView rows begin at 0, so you need to account for this
edit: you should add a return nil or @”” after the loop to catch the case where the item is missing. But as xlc0212 pointed out above, a different data structure would work better. My suggestion would be to have a dictionary like: