如何将此NSDictionary
数据填充到UITableView
我想要
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
从Dict获取数据的方法
2015-07-11 13:19:50.972 demo[1226:23659] {
posts = (
{
post = {
id = 1;
"school_id" = 1;
subject = Math;
};
},
{
post = {
id = 2;
"school_id" = 1;
subject = Science;
};
},
{
post = {
id = 3;
"school_id" = 1;
subject = English;
};
},
{
post = {
id = 5;
"school_id" = 1;
subject = Hindi;
};
},
{
post = {
id = 29;
"school_id" = 1;
subject = Biology;
};
}
);
}
答案 0 :(得分:0)
尝试这种方式从字典中获取数据
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// if you use custom cell then use this way code
FriendSelectionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"friendSelectionCell"];
// get value from dictionary
cell.yourlabel.text=[[[[self.dict objectForKey:@"posts"] objectAtIndex:indexPath.row] objectForKey:@"post"] objectForKey:@"id"];
return cell;
}