我有一个应用程序,其中有这样的 json 响应:
{
"status":"ok",
"dfs":[{"type":"i",
"title":"image",
"image_path":"https:\/\/s3.dhgdfhgfhgdhgfh\/ad_226.png"}]
}
我是这样解析的:
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);
}
但我得到这个错误:
*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0xde7ecf0”。
我将dict1
类文件夹作为nsmutable
数组。任何人都可以帮助我实现这一目标吗?