I've been searching around for about two hours now and it seems nobody has a clear explanation of how to read a JSON file in Objective C.
Let's say I have a JSON file called colors.json
, looking like this:
{
"colors": [{
"name": "green",
"pictures": [{
"pic": "pic1.png",
"name": "green1"
}, {
"pic": "pic2.png",
"name": "green2"
}]
}, {
"name": "yellow",
"pictures": [{
"pic": "pic3.png",
"name": "yellow1"
}]
}]
}
Where do I copy that file to in my XCode path?
How do I get this file programmatically?
After I have this file - How do I read the
name
value for eachcolors
object?How would I say "for each picture in the color with the name
green
, get thename
value in a NSString"?
I've been trying a few methods but haven't reached a conclusion yet. Am I just understanding the concept of a JSON wrong?