在iOS中解析JSON数组

在iOS中解析JSON数组,ios,objective-c,json,Ios,Objective C,Json,我试图从我的php生成的文件www.tiritium.com/standings.php中读取JSON数组,它在Android上运行良好,但我无法从文件中读取它。它可以正常打开,但我无法将NSDictionary放入NSArray //parse out the json data NSError* error; NSDictionary* json = [NSJSONSerialization JSONObjectWithD

我试图从我的php生成的文件www.tiritium.com/standings.php中读取JSON数组,它在Android上运行良好,但我无法从文件中读取它。它可以正常打开,但我无法将NSDictionary放入NSArray

 //parse out the json data
    NSError* error;
    NSDictionary* json = [NSJSONSerialization
                          JSONObjectWithData:responseData //1

                          options:kNilOptions
                          error:&error];

    NSArray* latestNames = [json objectForKey:@"name"]; //2

    NSLog(@"name: %@", latestNames); //3
我已将错误缩小到//2,但我似乎不知道发生了什么。我不确定是因为脚本输出了我的数据,还是因为应用程序本身的代码

2013-08-14 16:39:51.992 Derby Days[7951:c07] -[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x8a297b0
2013-08-14 16:39:51.993 Derby Days[7951:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x8a297b0'
是我收到的错误消息。

读取异常

-[__NSCFArray objectForKey:]: unrecognized selector

JSON的根是数组,而不是字典。

JSON文件表示数组,而不是字典。如果需要从中获取名称数组,可以使用键值编码,如
NSArray*names=[json valueForKey:@“name”]。这将为您提供一个
NSString
s数组