Php -[NSCFDictionary objectAtIndex:]:无法识别的选择器错误

Php -[NSCFDictionary objectAtIndex:]:无法识别的选择器错误,php,ios,objective-c,json,Php,Ios,Objective C,Json,我有一个简单的php文件,它给出了以下JSON数据: 我尝试了各种方法在iOS中解析这些数据,并在NSLog中简单地给出这些数据,例如: - (void) getData { NSURL *url = [NSURL URLWithString:@"http://bla.com/mapdata.php"]; NSData *data = [NSData dataWithContentsOfURL:url]; NSMutableArray *json = [NSJSONS

我有一个简单的php文件,它给出了以下JSON数据:

我尝试了各种方法在iOS中解析这些数据,并在NSLog中简单地给出这些数据,例如:

 - (void) getData {
    NSURL *url = [NSURL URLWithString:@"http://bla.com/mapdata.php"];
    NSData *data = [NSData dataWithContentsOfURL:url];

    NSMutableArray *json = [NSJSONSerialization 
                            JSONObjectWithData:data 
                            options:kNilOptions 
                            error:nil];

    NSLog(@"The size of json is %lu", (unsigned long)[json count]);

    for (int i = 0; i < json.count; i++) {
        NSDictionary *row = [json objectAtIndex:i];
        NSLog(@"a: %@, b:%@, c:%@", [row objectForKey:@"a"], [row objectForKey:@"b"], [row objectForKey:@"c"]);
    }
}
错误消息:-[\uu NSCFDictionary objectAtIndex:]:无法识别的选择器发送到实例0x1550a7d0


类似问题的其他答案无法帮助我解决问题,因此任何帮助都将不胜感激

JSON响应不是数组,它包含一个对象。所以你不能用

NSDictionary *row = [json objectAtIndex:i];
只需使用:

NSDictionary *json = [NSJSONSerialization 
                            JSONObjectWithData:data 
                            options:kNilOptions 
                            error:nil];
NSLog(@"a: %@, b:%@, c:%@", [json objectForKey:@"a"], [json objectForKey:@"b"], [json objectForKey:@"c"]);

您应该真正阅读错误消息并相信它。有人(您的代码)向字典发送消息objectAtIndex。因此,您认为是数组的东西实际上是字典。那会是什么?
NSDictionary *row = [json objectAtIndex:i];
NSDictionary *json = [NSJSONSerialization 
                            JSONObjectWithData:data 
                            options:kNilOptions 
                            error:nil];
NSLog(@"a: %@, b:%@, c:%@", [json objectForKey:@"a"], [json objectForKey:@"b"], [json objectForKey:@"c"]);