Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top