简体   繁体   English

没有互联网连接时,NSIncrementalStore如何工作?

[英]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.

相关问题 在没有互联网连接的情况下安装应用程序时,通用链接如何工作 - How universal links work when app is installed with no internet connection Internet连接(可恢复性)不起作用 - Internet connection (Rechability) not work 安装后,appcelerator studio 是否可以在没有互联网连接的情况下工作? - Does appcelerator studio work without internet connection once its installed? 没有互联网连接时,为什么我的Interstitial iAd崩溃了? - Why does my Interstitial iAd crash when there is no Internet connection? 成就完成处理程序无法检测到没有可用的Internet连接 - Achievement Completion Handler does not detect when no Internet connection is available SFSpeechRecognizer是否需要互联网连接? - Does SFSpeechRecognizer require internet connection? 在没有互联网连接的情况下如何防止应用程序在上传图像时崩溃 - How to prevent app crashing when uploading image when there is no internet connection 如何检测是否没有互联网连接 - How to detect if there no internet connection 没有互联网连接时会调用“ performFetchWithCompletionHandler”吗? - Is 'performFetchWithCompletionHandler' called when no internet connection? 没有互联网连接时调用“ didFailLoadWithError”? - Call “didFailLoadWithError” when no internet connection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM