0
我在其中我有這樣的JSON響應的應用程序:如何在iphone中解析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);
}
但我得到這個錯誤:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0xde7ecf0' .
我得到dict1
類文件夾爲nsmutable
數組。任何人都可以幫助我實現這個目標嗎?
titlelbl.text = [dict1 objectForKey:@「title」];這會工作嗎? – hacker
是的,在爲什麼我已經註釋掉的地方,寫在der上,它會工作.. – vishy
ohhh..thats working .. thanks buddy .. – hacker