[英]How does NSIncrementalStore work when there is no internet connection?
Title is the real question. 标题是真正的问题。 But some advice + sample code re: how to cope within nsincrementalstore subclasses when there is no internet connection would be great.
但是一些建议+示例代码重新:在没有Internet连接的情况下如何在nsincrementalstore子类中进行处理将非常有用。
I was thinking of caching to a sqlite persistent store so when an internet connection was unavailable I'd use a managed context that used the sqlite store instead of the incremental store.Not exactly sure on how the saving to the sqlite store would work to stay in sync with the web service (Parse in this case). 我当时想缓存到sqlite持久性存储,因此当无法使用Internet连接时,我会使用使用sqlite存储而不是增量存储的托管上下文。不确定要保存到sqlite存储的工作方式如何保持与Web服务同步(在这种情况下为解析)。
I suggest you rethink your architecture at a somewhat higher level. 我建议您在更高的层次上重新考虑您的体系结构。
Don't get down into the weeds of persistent stores and subclasses. 不要陷入持久性存储和子类的杂草中。 Instead, think about the transactions you need to save.
相反,请考虑您需要保存的事务。
Each modification you've made to the local store requires some sort of interaction with the web service. 您对本地存储所做的每次修改都需要与Web服务进行某种交互。 But those interactions are going to be messy: they'll fail, the server will be busy, network will come and go.
但是这些交互将变得一团糟:它们将失败,服务器将变得繁忙,网络将会来去去去。
If you think about this in two parts, the local data update and the remote data update, you'll have much more hair remaining at the end of your project. 如果您考虑本地数据更新和远程数据更新两个部分,那么在项目结束时将剩下更多的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.