iCloud + Core Data today (10th july 2015)

前端 未结 1 1024
醉梦人生
醉梦人生 2021-02-03 13:05

Some years ago Apple released the iCloud sync of Core Data apps. Then I released an app for iPad / iPhone / MAC with a shared model using the new Apple mechanism. Things have no

相关标签:
1条回答
  • 2021-02-03 13:54

    This is a question I've researched deeply in these last few months, I'm afraid without a definitive answer.

    Here's what I can tell you from my experience:

    1. If you, like me, don't want to start over with CloudKit, which works reliably but requires you to manually handle much of the syncing work and the conversion of CKRecords to ManagedObjects, give Ensembles.io a chance: it's working very well for me, the layer between Core Data and iCloud really is working in my case, where CD+iCloud didn't. I'm using the 1.0 version, which is open source and supports iCloud as one of its possible backends (and version 2.0, paid, supports even more); in a few days I got reliable sync with automatic de-duplication (you have to provide a uniqueIdentifier property to have it working, but I already had something in place...). The only issue I haven't figured out yet: sometimes (1 case out of 10, I'd say) an object doesn't sync right away when edited or deleted, but it always get on the other device when another object is added, edited or deleted: nothing got lost and everything has been handled "automatically" for me when these delays occurred, but still, I'd prefer that everything always synced right away. Ensembles also has a good logging for debug, something you'll appreciate coming from vanilla CD+iCloud. If you want to give it a try, you should take a look at these resources:

      • Ensembles.io company website
      • Ensembles on Github
      • A presentation/introduction from the creator of Ensembles
      • This, and other posts, on a blog I found after I implemented Ensembles in my Swift project; I could have used these informations, if I had found them before... but they're more useful if you're writing Swift code, if you're Objective C then the official Ensembles book is the way to go
    2. If you are absolutely sure that you don't want layers / third party code between Core Data and iCloud (I thought so myself, but I've changed my mind when I realized I lost three months of my life and got nothing in return), the implementations of Core Data + iCloud that I've found online and looked more promising were these:

      • Sample Library Style Core Data Apps with iCloud Integration, looks a bit complex to me, but I've read many good things
      • Tim Roadley's book and sample code

    I haven't tried myself these last two solutions, because my last plan of attack was to try Ensembles and, if it didn't work for me, go with those approaches. Since Ensembles has been very good to me, I didn't need to try them, but again they looked solid.

    One last thought that bothers me: in 2015 WWDC sessions there's no mention of Core Data + iCloud. This, to me, spells doom for the syncing solution we're choosing.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题