【发布时间】:2012-05-04 17:29:58
【问题描述】:
我开发了一个应用程序,在该应用程序中我需要从数组和数据库中删除行..?在 cellForRowAtIndexPath 中我像 cell.textLabel.Text=[myarray.objectAtIndexPath. row]; 我也想从数据库和数组中删除该行。在编辑方法中,我编写如下代码
MoneyAppDelegate *mydelegate=(MoneyAppDelegate *)[[UIApplication sharedApplication]delegate];
if (editingStyle == UITableViewCellEditingStyleDelete)
{
database *objdata=[[database alloc]init];
[app deleteCategory:objdata];
[self.mytableview deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
但它不起作用。在 deletecategory 方法中,我有类似
的代码-(void)deleteCategory:(database *)databaseObj
{
[databaseObj deleteCategory];
[myarray removeObject:databaseObj];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MoneyAppDelegate *app = (MoneyAppDelegate *)[[UIApplication sharedApplication]delegate];
静态 NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [app.myarray4 objectAtIndex:indexPath.row];
return cell;}
deletecategory 是从 Database.nothing 中删除记录的方法。 我如何从数据库中删除选定的行我知道它非常简单但我很困惑..thnanx 提前:)
【问题讨论】:
-
谢谢编辑,下次提醒
标签: objective-c ios cocoa-touch uitableview