以下作品一次:
self.fetchedResultsController = [Cat MR_fetchAllSortedBy:@"age" ascending:YES withPredicate:predicate groupBy:@"age" delegate:self inContext:[NSManagedObjectContext MR_defaultContext]];
但是设置新谓词并再次进行此调用不会刷新数据。如何清除缓存并强制fetchedResultsController获取新数据?
答案 0 :(得分:0)
您必须更改fetchedResultsController的谓词或sortDesctriptors属性。
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"startDate" ascending:YES];
[[fetchedResultsController fetchRequest] setSortDescriptors:@[sortDescriptor]];
或
[[fetchedResultsController fetchRequest] setPredicate:predicate];
..而且你再次获取
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle you error here
}
..并刷新你的tableView
[self.tableView reloadData];