K
K
KMichil2016-04-26 03:49:52
Objective-C
KMichil, 2016-04-26 03:49:52

How to get key value from nested NSArray(JSON) subarray?

I make a table with categories and subcategories from a JSON file of the form:
[
{
"id": "3b7",
"name": "Category1",
"subcategoryList": [
{
"id": "19e",
"name": "Subcategory1"
},
{
"id": "50a",
"name": "Subcategory2"
},
{
"id": "a9c",
"name": "Subcategory3"
},
{
"id": "b7e",
"name" :"Subcategory4"
}
]
},
{
"id": "c76",
"name": "Category2",
"subcategoryList": [
{
"id": "4fa",
"name": "Subcategory1"
},
{
"id": "b63",
"name": "Subcategory2"
}
]
}
]
Category will be the name of the UITableView section, subcategory cell. How to get and insert subcategoryList values ​​into cells?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seriogja, 2016-04-26
@KMichil

Hello!
You're looping through an array of categories, right? So! So you are converting json into a list of objects. I may not understand something in your example, but what is stopping you just inside the first cycle, if there is a subcategoryList element - to cycle through it and display subcategories?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question