I have an application in which i am having a json response like this:
{
"status":"ok",
"dfs":[{"type":"i",
"title":"image",
"image_path":"https:\/\/s3.dhgdfhgfhgdhgfh\/ad_226.png"}]
}
and I am parsing like this:
NSDictionary *dict=[[request responseString] JSONValue];
NSLog(@"dict %@ ",[request responseString]);
if([[dict objectForKey:@"status"] isEqualToString:@"ok"])
{
NSMutableDictionary *dict1=[dict objectForKey:@"dfs"];
NSLog(@"%@",[dict1 classForCoder]);
NSLog(@"%@dict1",dict1);
titlelbl.text=[dict1 objectForKey:@"title"];
if ([[dict1 objectForKey:@"type"] isEqualToString:@"i"])
{
ad.hidden=NO;
NSString *imageurl=[dict1 objectForKey:@"image_path"];
NSLog(@"%@",imageurl);
}
But I get this error:
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0xde7ecf0’ .
I got the dict1 class folder as nsmutable array. Can anybody help me in how to achieve this?
read the json response as above, its a dictionary, within it first object is string, second is an array of dictionary (which has only one object).