I have an iOS application which downloads and parses a JSON file from the Facebook API.
However, whenever I try to parse it my app crashes and I get this error:
2013-11-06 15:31:41.473 JSONTESTER[10881:70b] -[__NSCFDictionary objectAtIndex:]: unrecognized
selector sent to instance 0x10d01bd30
2013-11-06 15:31:41.476 JSONTESTER[10881:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x10d01bd30'
Here is the simple JSON file I am trying to parse:
{
"id": "xxxxxxxxxx",
"name": "Dan Sadjadian",
"home": {
"data": [
{
"id": "xxxxxxxxxxxxxxxxxxxxxx",
"from": {
"name": "Jane Smith",
"id": "xxxxxxxxxxxxxxx"
},
"message": "deadline is only 16 days!!! Where are you guys!!!!!!!!! Please shall we start!!!!!",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/xxxxxxx/posts/xxxxxxxxxxx"
},
{
"name": "Like",
"link": "https://www.facebook.com/xxxxxxxxx/posts/xxxxxxxxxxxx"
}
],
"privacy": {
"value": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2013-11-06T14:40:23+0000",
"updated_time": "2013-11-06T14:40:23+0000"
},
],
},
}
Here is my code which should work....
cell.username.text = [[[[[facebook_array objectAtIndex:index] valueForKey:@"data"] objectAtIndex:0] valueForKey:@"from"] valueForKey:@"name"];
As you can see I am trying to get access to "name" which is in "from" which is in the "data" array which is in "home".
What am I doing wrong?
Thanks, Dan.