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);
你能給JSON的例子,當您訪問的頁面使用Web瀏覽器? – Undo 2014-09-10 16:41:12
你能解釋你如何初始化你的可變數組:故事' – CoderPug 2014-09-10 16:43:30
對不起,它位於文件NSMutableArray *故事的頂部; – Jim 2014-09-10 16:44:55