我正在使用CoreData + UITableView处理待办事项列表应用程序,我想隐藏用户标记为已完成的行。隐藏UITableViewCell的特定行
我当前的解决方案是在用户标记任务完成时调用deleteRowsAtIndexPaths,并从numberOfRowsInSection的函数中扣除删除的行。
-(void)markDone:(NSIndexPath *) _indexPath{
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:_indexPath] withRowAnimation:UITableViewRowAnimationFade];
deletedCount = deletedCount + 1;
[self.tableView endUpdates];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
if (deletedCount>0) {
return [sectionInfo numberOfObjects]-deletedCount;
}
return [sectionInfo numberOfObjects];
}
这种方法虽然没有工作,但我确实需要一些代码在这里,有黑客。有没有办法调用NSFetchedResultsController didChangeObject改变特定字段的状态?
谢谢
对我来说似乎是正确的,您是否考虑过使用两个列表来处理您的数据,一个是针对所有人的,一个是针对尚未标记为已完成的数据? – ThomasRS 2011-05-05 16:42:36
宁愿单个列表。我不太确定如何在核心数据中使用两个列表。大声笑。 – TonyTakeshi 2011-05-05 17:32:25