iCloud + Core Data今天(2015年7月10日) [英] iCloud + Core Data today (10th july 2015)

查看:174
本文介绍了iCloud + Core Data今天(2015年7月10日)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几年前,苹果发布了Core Data应用程序的iCloud同步。然后我发布了一个应用程序的iPad / iPhone / MAC与共享的模型使用新的苹果机制。
事情没有按预期的。同步机制有时不工作。例如,在最后几个月,在我的情况下,很少同步结束通过我的3个设备。上传对象一般工作正常。但是新的或删除的对象的下载过程正常崩溃。
Apple早些时候发布了一种强制设备重新下载模型的所有对象(NSPersistentStoreRebuildFromUbiquitousContentOption)的方法,这些对象都可以正常工作,但不是可接受的解决方案。

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 not gone as expected. The sync mechanism sometimes doesn't work. For example, the last months, in my case, rarely the sync ends well through my 3 devices. Uploading objects in general works fine. But the download process of new or deleted objects normaly crash. Apple released some time ago a way to force the devices to redownload ALL the objects of the model (NSPersistentStoreRebuildFromUbiquitousContentOption) that normaly works but it's not an acceptable solution.

我的问题:有人完成了让iCloud + Core Data工作正常吗?如何在iOS 9 + El capitan下运行iCloud + CD,任何体验?

My questions: Does someone have accomplished to get iCloud + Core Data working fine? What about running iCloud+CD under iOS 9 + El capitan, any experience?

我正在评估迁移到新的CloudKIT API, - 如果设备离线,管理对象上传。

I'm evaluating migrate to new CloudKIT API but I don't like the idea of self-manage an object upload if the device is offline. Does the new mechanism of push notifications indicating model changes works fine?

感谢

推荐答案

这是我在过去几个月深入研究过的一个问题,恐怕没有明确的答案。

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. 如果你像我一样不想重新开始使用CloudKit,手动处理大量的同步工作和CKRecords到ManagedObjects的转换,给予 Ensembles.io 一个机会:它对我来说工作得很好,Core Data和iCloud之间的层真的在我的情况下工作,其中CD + iCloud没有。
    我使用1.0版本,这是开源,并支持iCloud作为其可能的后端之一(和版本2.0,支付,支持更多);在几天内,我得到可靠的同步与自动重复数据删除(你必须提供一个uniqueIdentifier属性,让它工作,但我已经有一些东西到位...)。
    我还没有想到的唯一问题:有时(10例中有1例,我想说)一个对象在编辑或删除时不会立即同步,但它总是在其他设备上另一个对象被添加,编辑或删除:没有什么丢失,一切都已经被自动处理,当这些延迟发生,但仍然,我宁愿一切总是立即同步。
    Ensembles还有一个很好的日志记录调试,你会喜欢来自香草CD + iCloud。
    如果你想尝试一下,你应该看看这些资源:

  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

如果您绝对确定您不想在Core Data和iCloud之间使用图层/第三方代码所以我自己,但我改变了主意,当我意识到我失去了三个月的我的生活,没有回报),Core Data + iCloud的实现,我在网上找到,看起来更有前途是:

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

我没有尝试过这两个解决方案,因为我的上一个攻击计划是尝试Ensembles,如果它不能为我工作,方法。因为Ensembles对我很好,我不需要尝试他们,但是他们看起来很坚固。

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.

最后一个想法困扰我:在2015年WWDC会议没有提到Core Data + iCloud。对我来说,这是对我们选择的同步解决方案的厄运。

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.

希望这有助于。

这篇关于iCloud + Core Data今天(2015年7月10日)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆