Well, therefore, to answer my own question, I implemented the cache as follows:
Another class is created that saves the entity (NSEntityDescription), the selection predicate (NSPredicate), and the NSFetchPredicate sorting descriptors (NSArray), as well as sectionNameKeyPath objects and additional BSFetchedResultsController objects (predicate, filter, comparator). Make this class compatible with NSCoding.
Then, at the beginning of the performFetch method: if there is a cache name, unzip the object and see if the BSFRC properties match, and if so, use the data in the cache section.
Then add another notification handler to NSManagedObjectContextDidSaveNotification to clear the objects before the cache.
A few points ... I found that archiving NSFetchRequest directly (which corresponds to NSCoding) does not work, and at the moment I am only checking the name NSEntityDescription.
In addition, I do not cache the entire object graph, but only the URIR representation of the NSManagedObject NSManangedObjectID data. Then I repeat these URIs based on the context of the managed entity after checking the cache.
It seems to work, although I'm not sure how often I have to clear objects to cache ...
Daniel Thorpe
source share