I have a Core Data layer with several thousand objects that is constantly in sync with the server. The synchronization process uses sample queries to check for delete_at for soft deletion. There is one context that performs save operations in an executeBlockAndWait call. Relationship mapping is handled by the RestKit library.
The CoreDataEntity class is a subclass of NSManagedObject, and it is also a superclass for all of our various classes of master data objects. It has some attributes that are inherited by all our objects, such as deleted_at, entity_id, and all methods of selecting and synchronizing templates.
My problem is that some select queries seem to return inconsistent results after making changes to the objects. For example, after deleting an object (setting deleted_at to the current date):
[CoreDataEntity fetchEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"deleted_at==nil"]];
Returns results using deleted_at == [NSDate today]
I successfully worked on this behavior, additionally sorting through the results and deleting entities using set_set, however, I cannot fix the opposite problem:
[CoreDataEntity fetchEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"deleted_at!=nil"]];
It returns an empty array under the same conditions, which prevents subsequent server synchronization.
I confirmed that the object is set to delete_at, and saving the context was successful. I just donβt understand where to reset which cache causes stale results?
Thanks for any help!
Edit: By adding a little more information, it seems that as soon as one of these objects is damaged, the only way to get it to register is to change the value again. Could this be some kind of Core Data index not updating when the value changes?
Update: seems to be a problem with RestKit https://github.com/RestKit/RestKit/issues/2218