【发布时间】:2012-09-17 02:53:17
【问题描述】:
- (void)receiveData:(NSData *)data {
self.office = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
self.files = [office objectForKey:@"files"];
[self.myTableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.files.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc] init];
NSDictionary *file = [self.files objectAtIndex:indexPath.row];
cell.textLabel.text = [file objectAtIndex:1]; //here i want to get data from the array
cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
cell.textLabel.numberOfLines = 1;
return cell;
NSLog(@"files:\n%@", file);
}
我有一个 json 响应,我存储在 NSDictionary 办公室中,并且该 json 中的数组存储在 NSArray 文件中,现在我已将文件数组提供给另一个 NSDictionary 文件,并根据存储在该文件中的数据我想要该数据在我的表格行中,但我的文件数组中没有任何“键”,只有该数组中的值,
所以我的问题是,我如何在我的文件字典中指出该值,我已在我想要的地方发表评论,请查看该评论....
【问题讨论】:
-
你为什么不用
[file objectAtIndex:indexPath.row];? -
[文件 objectAtIndex:indexPath.row]; //不起作用
-
[文件 objectAtIndex:indexPath.row]; //有效
-
没有键的字典怎么办?
-
记录文件并检查您想要显示和使用的内容..
标签: iphone ios json uitableview