2014-09-10 23 views
0

我有一个可变数组故事,我试图添加JSON响应的副本,但它产生O故事并且没有数组。我究竟做错了什么? JSON对象格式正确,我可以单独显示每个组件,但它们不会添加到数组中。Xcode添加可变字典从JSON到可变数组

NSString *[email protected]"http://www.foo.com/some.php"; 
NSURL *url=[NSURL URLWithString:str]; 
NSData *data=[NSData dataWithContentsOfURL:url]; 
NSError *error=nil; 
NSMutableDictionary *response=[NSJSONSerialization JSONObjectWithData:data options: 
      NSJSONReadingMutableContainers error:&error]; 

NSLog(@"Your JSON Object: %@", response); 


NSLog(@"Location: %@", response[@"location"]); 
NSLog(@"Service ID: %@", response[@"serviceID"]); 
NSLog(@"Problem: %@", response[@"problem"]); 

[stories addObject:[response copy] ]; 

NSLog(@"Workorders: %d", [stories count]); 
NSLog(@"WO Defined: %@",stories); 
+0

你能给JSON的例子,当您访问的页面使用Web浏览器? – Undo 2014-09-10 16:41:12

+0

你能解释你如何初始化你的可变数组:故事' – CoderPug 2014-09-10 16:43:30

+0

对不起,它位于文件NSMutableArray *故事的顶部; – Jim 2014-09-10 16:44:55

回答

0

你去那里......试试这个

NSMutableArray *stories = [NSMutableArray array];