동시에 tableview에 키를 표시하는 방법은 무엇입니까? 여기에 값을 표시 할 수 있습니다. "A"키를 tableview에 표시하는 방법
하세요 @ ..
: 나는 cell.textLabel의 setText에 키를 표시 할. . .
여기 내 코드입니다 고마워요 고맙습니다. NSURLRequest * request = [NSURLRequest requestWithURL : [NSURL URLWithString : @ "https://reserve.cdn-apple.com/AU/en_AU/reserve/iPhone/availability.json"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
_listarr = [[NSMutableArray alloc]init];
id list = [dic objectForKey:self.strStore];
if ([list isKindOfClass:[NSDictionary class]]) {
NSDictionary *dictionary = (NSDictionary *)list;
NSArray *keys = [list allKeys];
for (NSString *key in keys) {
NSString *teamname = (NSString *)[dictionary objectForKey:key];
NSLog(@"",key);
[_listarr addObject:[NSString stringWithFormat:@"%@", teamname]];
}
} else {
// Do some error handling
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//必须返回与数据容器一样的数量,否则会报数据越界错
return [_listarr count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"thisCell";
UITableViewCell *cell;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
[cell.textLabel setText:@"A"];
[cell.detailTextLabel setText:[_listarr objectAtIndex:indexPath.row]];
return cell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
@end
있는 NSDictionary는 키와 값을 가지고있는 NSArray는 값이 – CSmith