我想从数据库插入数据到表。 我能够从数据库获取数据并将其插入表中,但只有最后一个数据插入到表的所有行中。我已经使用了代码从数据库插入数据到表
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
Action *actionInformation;
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 460) reuseIdentifier:@"MyIdentifier"] autorelease];
PrepopulatedActionsDao * preAction = [[PrepopulatedActionsDao alloc] init];
[preAction getDataFromDatabase];
NSMutableArray *allPreActions=[preAction getDataFromDatabase];
for(int i=0;i<[allPreActions count];i++){
actionInformation=[allPreActions objectAtIndex:i];
cell.textLabel.text = [NSString stringWithFormat: @"%@",actionInformation.action];
}
}
return cell;
}
这里PrepopulatedActionsDao就是我从数据库中获取所有提交的数据的类。
我想插入数据库的所有数据在表中不仅是最后一个。 请有人帮忙。
是什么的UITableView类的numberOfRowsInSection价值? – Sarah 2012-02-06 08:43:01
@Sarah:它的100作为数据库中的数据是100. – hgpl 2012-02-06 08:44:37