Reputation: 15138
here is my JSON Output I got:
{
"success":true,
"return":{
"an":[
{
"ordner_id":1,
"name":"Eingang",
"gesamt":"1415",
"ungelesen":"0"
},
{
"ordner_id":3,
"name":"Gel\u00f6scht"
},
{
"ordner_id":"42864",
"name":"Test1",
"gesamt":"0",
"ungelesen":"0"
}
],
"von":[
{
"ordner_id":2,
"name":"Gesendet"
},
{
"ordner_id":3,
"name":"Gel\u00f6scht"
}
]
}
}
I can get the "success" and the "return" value easily (BOOL and NSDictonary) with this lines:
NSDictionary *ensFolderListFirstReturn = [ENSHandler GetENSFolderList];
BOOL success = [[ensFolderListFirstReturn objectForKey:@"success"] boolValue];
if (success)
{
ensFolderList = [ensFolderListFirstReturn objectForKey:@"return"];
}
But when I try to get the "an"-value with this:
NSDictionary *ensFolderList1 = [ensFolderList objectForKey:@"an"];
I got a BAD EXEC-error.
What am I doing wrong?
Upvotes: 0
Views: 218
Reputation: 1349
I think you are trying to directly getting an NSDictionary object from an NSDictionary. I don't think that this is a good way. Try to get the NSArray object from the NSDictionary like:
NSArray *ensFolderArray = [ensFolderList objectAtIndex:0];
NSLog(@"%@",ensFolderArray);
Now try to see on console that are you getting the required "an" object or not and give your response.
Happy Coding!
Upvotes: 0
Reputation: 21903
Looks like the "an" value holds a list, not a dictionary. Try:
NSArray *ensFolderList1 = [ensFolderList objectForKey:@"an"];
Each element of that array will hold an NSDictionary.
Upvotes: 2