首页 文章

从数组Iphone中删除对象

提问于
浏览
0

我在tableview类中有2个NSMutableArraL . 一个数组包含一个列表,第二个数组包含子列表 .

当我从列表数组中删除对象时,我想从subList数组中删除与list数组相同的indexPath中的对象 .

NSLog在删除对象之前和之后提供了两个数组中对象的正确计数,但是当我在表上加载subList数组的视图时,看起来subList数组的所有单元都是空的 .

一个更重要的信息是每个subList对象都是数组 .

这是删除单元格的功能:

  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
[list removeObjectAtIndex:indexPath.row];
NSLog(@"delete list: %d",[list count]);

[subList removeObjectAtIndex:indexPath.row];
NSLog(@"delete subList: %d",[subList count]);

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject: indexPath] withRowAnimation:UITableViewRowAnimationTop];

[self saveData];

}

我希望我的问题很明确 . 谢谢EKT

1 回答

  • 0

    您是否尝试在更改阵列后调用[UITableView reloadData]?表视图可能无法正确刷新 .

相关问题