简体   繁体   中英

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.

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).

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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