我想让我的NSdictionary值到UITableViewCell中。这是我的字典格式:NSDictionary allkeys到UITableViewCell
{
date = "3/4/14, 3:33:01 PM Pacific Standard Time";
weight = 244;
}
这是我用来填充我的uitableview(这是不工作)的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"WeightCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
NSArray* allKeys = [weights allKeys];
NSDictionary *obj = [allKeys objectAtIndex: indexPath.row];
cell.textLabel.text = [obj objectForKey: @"date"];
cell.detailTextLabel.text = [obj objectForKey:@"weight"];
return cell;
}
定义“不工作”。出了什么问题。请记住,字典没有顺序。这两个键每次都可以按不同顺序排列。 – rmaddy
好的。通过不工作,我没有得到的tableview填充我的字典'权重'的数据。也许我不是那么正确的方式。 – TerryG
您正在使用字典对象作为另一个字典上另一个对象的关键字? – J2theC