3
votes

I'm using Ulysses application for iPad. This app uses iCloud as a sync system. In case of conflicts the app shows a popover with the descriptions of the devices involved.

In particular:

  • Name of the device (e.g. Matteo's Macbook Pro)
  • Time stamps (e.g. 22nd March 2015 9:34)

Choosing the right version of the note it's than possible to complete the synchronization.

I've already setup the icloud stack to handle the synchronization, and it works pretty good but i can't figure out how, in case of conflicts, retrieve that kind of informations.

Any suggestions?

1
Welcome to stackoverflow. Your question is too broad. You need to demonstrate a minimum of research and then ask the community when you get stuck.Mundi
I've already setup the icloud stack to handle the synchronization, and it works pretty good but i can't figure out how, in case of conflicts, retrieve that kind of informations (device name, timestamp). ThanksMatteo Mosca
OK, you should mention that in your question. Did you try to create a conflict and see what happens?Mundi
It automatically manages conflicts with the default policy. It calls the callback associated with event "NSPersistentStoreDidImportUbiquitousContentChangesNotification". In the callback, as a parameter, i have a NSNotification* but it doesn't have that infos... PS: thanks for the suggestions you gave about my question :)Matteo Mosca

1 Answers

0
votes

Listen for the NSPersistentStoreDidImportUbiquitousContentChangesNotification and rather than just calling mergeChangesFromContextDidSaveNotification:, first examine the two versions.

This can be done by retrieving the userInfo dictionary of the notification which should contain the NSManagedObjectIDs of the changed objects under the NSUpdatedObjectsKey.