JSON 数据处理问题

JSON Data handling issue

 [manager POST:@"myurl here" parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
            NSLog(@"Response %@", responseObject);


if ([responseObject[@"code"]isEqualToString: @"202"] )
            {

               totalorders = responseObject[@"orders"];
                for (int i= 0 ; i< [totalorders count]; i++)
                {
                    dataDictionary =[[totalorders objectAtIndex:i]objectForKey:@"odate"];


                    [dates addObject:[dataDictionary objectForKey:@"odate"]];

                    NSLog(@"%@",dataDictionary );


                }


            }


这个我也试过了

dates addobject: [dataDictionary allValues];

我记录的是日期,现在我无法存储从 datadictionaryNSarray 的数据 需要帮助。
谢谢 稍后我必须在 tableview 中显示数据..
请提供一些 link 到 JSON 解析 基础知识

<br><br> My Output is 2015-01-15 16:56:54.851 Test Application [4245:474718] 2015-01-12
2015-01-15 16:56:54.851 Test Application[4245:474718] 2015-01-08
2015-01-15 16:56:54.852 Test Application[4245:474718] 2015-01-08
2015-01-15 16:56:54.852 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.852 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.853 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.853 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.854 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.855 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.855 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.855 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.856 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.858 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.858 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.859 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.859 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.859 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.860 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.860 Test Application[4245:474718] 2015-01-05
2015-01-15 16:56:54.861 Test Application[4245:474718] 2015-01-02
2015-01-15 16:56:54.861 Test Application[4245:474718] 2014-11-25
2015-01-15 16:56:54.861 Test Application[4245:474718] 2014-11-25
2015-01-15 16:56:54.862 Test Application[4245:474718] 2014-11-25
2015-01-15 16:56:54.862 Test Application[4245:474718] 2014-11-25
2015-01-15 16:56:54.863 Test Application[4245:474718] 2014-11-17
2015-01-15 16:56:54.863 Test Application[4245:474718] 2014-11-17
2015-01-15 16:56:54.866 Test Application[4245:474718] 2014-11-17
2015-01-15 16:56:54.867 Test Application[4245:474718] 2014-11-13
2015-01-15 16:56:54.867 Test Application[4245:474718] 2014-11-13
2015-01-15 16:56:54.868 Test Application[4245:474718] 2014-11-13
2015-01-15 16:56:54.868 Test Application[4245:474718] 2014-11-13
2015-01-15 16:56:54.868 Test Application[4245:474718] 2014-11-13
2015-01-15 16:56:54.869 Test Application[4245:474718] 2014-11-13
2015-01-15 16:56:54.869 Test Application[4245:474718] 2014-11-12
2015-01-15 16:56:54.870 Test Application[4245:474718] 2014-11-12
2015-01-15 16:56:54.870 Test Application[4245:474718] 2014-11-10
2015-01-15 16:56:54.871 Test Application[4245:474718] 2014-11-10
2015-01-15 16:56:54.871 Test Application[4245:474718] 2014-11-10
2015-01-15 16:56:54.871 Test Application[4245:474718] 2014-11-10
2015-01-15 16:56:54.872 Test Application[4245:474718] 2014-11-06
2015-01-15 16:56:54.872 Test Application[4245:474718] 2014-11-05
2015-01-15 16:56:54.874 Test Application[4245:474718] 2014-11-05
2015-01-15 16:56:54.874 Test Application[4245:474718] 2014-11-05
2015-01-15 16:56:54.875 Test Application[4245:474718] 2014-11-05

您已使用以下代码行正确下钻到日期对象

[[totalorders objectAtIndex:i]objectForKey:@"odate"]

因此无需为同一个键再次获取对象

此外,当您尝试将 nil 对象添加到数组时可能会崩溃但是很惊讶地发现事实并非如此,所以您可能没有分配 'dates' 数组

下面是修复了问题的代码

dates=[NSMutableArray new];
if ([responseObject[@"code"]isEqualToString: @"202"] )
            {

               totalorders = responseObject[@"orders"];
                for (int i= 0 ; i< [totalorders count]; i++)
                {
                    dataDictionary =[[totalorders objectAtIndex:i]objectForKey:@"odate"];


                    [dates addObject:dataDictionary];

                    NSLog(@"dates %@",dates );


                }


            }

请注意,发送到 nil 对象的消息不会导致崩溃,但添加 nil 对象会导致崩溃