简体   繁体   English

Restkit和核心数据回滚

[英]Restkit and Core Data rollback

In my app I'm using RestKit v0.23.3 and I need to call 4 web service sequentially. 在我的应用中,我使用的是RestKit v0.23.3,我需要依次调用4个Web服务。 I'm doing this without any problem following various tutorial that can be found on the web. 我正在按照网上的各种教程进行操作,没有任何问题。

My problem is that I need to be sure to download all 4 services or data can be inconsistent. 我的问题是我需要确保下载所有4个服务,否则数据可能会不一致。

Now my question : can I do a rollback on CoreData if one of the web services fails during the download/mapping operations ? 现在我的问题是 :如果其中一个Web服务在下载/映射操作期间失败, 可以对CoreData进行回滚吗? Or is there a mode to disable the "auto save to persistent store" feature that RestKit has and save "manually" only when the last web service has ended ? 还是有一种模式可以禁用RestKit拥有的“自动保存到持久性存储”功能并仅在最后一个Web服务结束时“手动”保存?

Thanks in advance for your help. 在此先感谢您的帮助。

If this is really required then I'd be tempted to use a disk based solution - ie before you start any potentially destructive / corrupting operation you ensure everything is saved and make a copy of the data store on disk (note that multiple files may need to be saved so best to use API like migratePersistentStore:toURL:options:withType:error: ). 如果确实需要这样做,那么我很想使用基于磁盘的解决方案-即,在开始任何可能的破坏/破坏操作之前,请确保所有内容都已保存并在磁盘上复制数据存储(请注意,可能需要多个文件要保存起来,以便最好使用API​​,例如migratePersistentStore:toURL:options:withType:error: Now, if you have a problem you can tear the Core Data stack down, restore from disk and then recreate the stack. 现在,如果您有问题,可以将“核心数据”堆栈拆解,从磁盘还原,然后重新创建堆栈。 This is safer and more reliable than trying to prevent saving or use an undo manager as the load process is run across multiple threads so you really need the saves to be running. 这比尝试阻止保存或使用撤消管理器更安全,更可靠,因为加载过程跨多个线程运行,因此您确实需要运行保存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM