iCloudCoreDataStack icon indicating copy to clipboard operation
iCloudCoreDataStack copied to clipboard

Migration Issues with duplicate entries

Open HaFondEcran opened this issue 10 years ago • 1 comments

Hello,

I have an already existing core data apps synchonized by dropbox and I want to migrate on iCloud (with iCloudCoreDataStack). And have 2 devices ( iPhone and iPad) with the same data inside.

I update the ipad apps to the new apps with icloud, everything work fine and synchonisation works.

When I update the iphone, all core data entries are duplicates, I under why : I merge and existing store with the icloud store with the same information. If you have and idea to avoid that ...

HaFondEcran avatar Jan 09 '14 12:01 HaFondEcran

Hi, You need to do your own de-duplication either when you migrate a non-iCloud store to iCloud and also when you merge changes that have occurred on another device. The de-duplication algorithm you use will depend on your data.

Core Data doesn't know that your records are the same, it creates a unique GUID type key for every record that is created. Even two records with identical data will have a different Core Data ID. When store migration or data merges happen you have to have a method that determines, based on a unique key that is suitable for your data, which records are duplicates and can therefore be removed.

I hope that helps.

mluisbrown avatar Jan 13 '14 21:01 mluisbrown