-
Notifications
You must be signed in to change notification settings - Fork 40
Error getting relationships from CloudKit #27
Comments
I think the problem is there's no dependency order in the recordChangedBlock of CKFetchRecordZoneChangesOperation, then if both records are new, the block may be called with a reference to another record that might not exist yet in CoreData. Just created a pull request with a possible fix: It stores the records until fetch is completed, and then tries to process them in relationship order when the topological sort in the entity graph is possible. If it's not possible then it performs the update operations many times so all the relationships are fullfilled. Bests |
@juanip027 it's rather hard to test that, could you confirm that your pull request fixed that issue for you? |
Hi Vasily, yes it worked for both my model and the example app model too. Also there is minimum chance to add new bugs in this pull request because it only sort the entities to process them but the update process keeps the same. |
Hi juanip027, When more than a few objects are changed, your solution to iterate cycleLength times for every changed record is producing a lot overhead. I can add a pr with an alternate solution for the relationship problem. In it I am tracking the relationship and entity if a managedObject is not found and insert them after all NSManagedObjects from CloudKit are created. |
Hi Oleg, Apple recommends that you specify inverse relationships but in the model they are optional so it can be a DAG, and in this case the topologicalSort is the best solution. |
@Scytalion Could you open pull request with your solution? I will try to add specific performance tests and check real difference between solutions. |
@juanip027 |
Some relations are broken (nullified) in CoreData when you get data from CloudKit.
The text was updated successfully, but these errors were encountered: