문제

I have a simple app that uses core data to persist data fetched on the web. I use NSFetchedResultsController to populate aUITableView with that data. I am using a cache on the NSFetchedResultsControllers results set like this:

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"MyCache"];

Is there a way to invalidate the cache when I update my data model when synchronizing with a web service? Or shouldn't I be using any cache at all?

도움이 되었습니까?

해결책

You don't need to delete the cache just because you synchronised data. You only need to delete the cache (using deleteCacheWithName:) when you change the fetch request predicate / sort. Synchronisation changes will simply update the controller and update the cache.

You don't want to use a cache if you change the fetch predicate / sort frequently.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top