I download a list of sports teams. The contents of the JSON list must then be presented in a UIPickerView. Here is the contents of the JSON;
{
success: "true",
message: [
{
category_id: 21,
category_name: "MAN UTD",
parent: "EPL"
},
{
category_id: 22,
category_name: "Liverpool",
parent: "EPL"
},
{
category_id: 27,
category_name: "Real Madrid",
parent: "La Liga"
},
{
category_id: 75,
category_name: "Barcelona",
parent: "La Liga"
},
{
category_id: 23,
category_name: "Valencia",
parent: "La Liga"
},
{
category_id: 24,
category_name: "Bayern Munich",
parent: "Bundesliga"
}
]
}
I know how to parse the JSON, but I need to present the UIPickerView with the parent above the associated teams.
So I need to add them to an array like so;
EPL, Man Utd, Liverpool, La Liga, Real Madrid, Barcelona, Valencia, Bundesliga, Bayern Munich.
Is there a clean way to do this in a conditional statement? I need to be able to sort them like above, but it would be great if it could handle dynamic content incase the list gets added to etc.