I'm syncing a core-data app with iCloud and none of the documentation says in what circumstances you'd choose one NSMergePolicy over the other. I'm using NSMergeByPropertyStoreTrumpMergePolicy, but I sometimes get random deletions. Is there another one I should be using?
2 に答える
ntesler,
Each merge policy has different goals. I always default to background threads using NSMergeByPropertyStoreTrumpMergePolicy
and have the main thread use NSMergeByPropertyObjectTrumpMergePolicyType
. The main time the these policies matter is when you are calling -refreshObject:mergeChanges:
. When you set mergeChanges
to YES, then the respective truth is chosen as directed by the policy.
I've not used iCloud and hence cannot advise you on if it changes the above analysis. In my experience though, you need to choose one repository to be the "truth". Is the iCloud always the truth? I expect it should be.
Andrew
NSMergeByPropertyObjectTrumpMergePolicy
is the merge policy that worked best for me. NSMergeByPropertyStoreTrumpMergePolicy
sometimes resulted in inconsistent merging between devices, at least in memory.