我尝试从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]:无法识别的选择器发送到实例
答案 0 :(得分: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]);
}
}