CoreData and iCloud

后端 未结 3 989
梦如初夏
梦如初夏 2020-12-22 22:31

I am developing a core data application and was thinking of adding iCloud support, but after looking around on the web I frequently heard that iCloud+CoreData is unreliable

相关标签:
3条回答
  • 2020-12-22 22:34

    In macOS 10.15 and iOS 13 Apple has introduced NSPersistentCloudKitContainer which is

    A container that encapsulates the Core Data stack in your app and mirrors select persistent stores to a CloudKit private database.

    Links:

    Apple Documentation: Mirroring a Core Data Store with CloudKit

    Apple Sample Code: Synchronizing a Local Store to the Cloud

    0 讨论(0)
  • 2020-12-22 22:42

    The link to the video has changed: https://developer.apple.com/videos/wwdc/2013/?id=207

    Edit: This should be a comment to the last answer but I don't have the required 50+ reputation :(

    0 讨论(0)
  • 2020-12-22 22:58

    Now that iOS 7 has been released, we can talk about it. And everything would seem to indicate that in iOS 7 iCloud Core Data sync has been fixed. I'm about to add iCloud Core Data sync to an (iOS 7 only) app I'm building, so I can't yet speak from personal experience, but everything I've heard suggests that it's now good for prime time.

    I highly recommend watching the "What's New in Core Data and iCloud" session video from WWDC 2013: https://developer.apple.com/videos/wwdc/2013/?id=207 (requires an Apple Developer Program membership). I've watched it twice now, and they've certainly made things a lot more straightforward.

    Lastly, I recommend taking a look at UbiquityStoreManager on GitHub. It's a library that pretty much does all the painful parts of iCloud Core Data for you. It's been modified to take into account the significant improvements in iOS 7, all though if you want to take advantage of them your app has to be iOS 7 only (that applies whether you use the library or not).

    UPDATE: Since posting this answer, I now can speak from personal experience, and can confirm that Core Data iCloud Sync in iOS 7 is rock solid, and what's more, unbelievably easy to implement. I added it to my app without using UbiquityStoreManager or any other 3rd party library and it was very straightforward. Literally just a few lines of code.

    EDIT: I created a GitHub repo with my iCloud Core Data stack for iOS 7. Hope it helps: https://github.com/mluisbrown/iCloudCoreDataStack

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