0

我尝试从 url 获取 json 数据,但我得到 ERROR 这是我的代码;

self.NsData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://doctorapp.5plus.co.il/categories.php"]];
id jsonCategories=[NSJSONSerialization JSONObjectWithData:NsData options:NSJSONReadingMutableContainers error:nil];
self.categoriesArray=[jsonCategories allKeys];
NSLog(@"%@",[self.categoriesArray objectAtIndex:0]);

这是我的错误:

[__NSArrayM allKeys]:发送到实例的无法识别的选择器

4

1 回答 1

0
self.data=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://doctorapp.5plus.co.il/categories.php"]];
self.categoriesArray=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
self.categoriesNames=[[NSMutableArray alloc]init];
for (int i = 0; i < [self.categoriesArray count]; i++) {
        NSDictionary * dic = [self.categoriesArray objectAtIndex:i];
        NSString * k;
        for (k in [dic allKeys]) {
            [self.categoriesNames addObject:[dic objectForKey:k]];
            NSLog(@"Temporary ports: %@", [dic objectForKey:k]);
        }
}
于 2013-02-25T17:22:11.250 回答