RestKit / RestKit

RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X
Apache License 2.0
10.17k stars 2.1k forks source link

Clarify Documentation Regarding Offline Usage #1190

Open blakewatters opened 11 years ago

blakewatters commented 11 years ago

This issue was extracted from a follow-up comment on #1183 by @phaser82:


Hello, I've been running in a similar bug related to switch between offline and online use of my app. Now I've understand what's behind this fix which I can confirm it actually works. Thanks. Anyway I think I'm missing something regarding how to manage completely offline/online use. Maybe someone could point me out on the best solution.

More specifically...I can divide my case in three situation - Scenario of "creating new object":

Always Online: using the mainQueueManagedObjectContext after a postObject everything works fine. My object get saved server side and client side (persistent store). So restkit manage on its own passing my object from mainQueueManagedObjectContext to persistentStoreManagedObjectContext and then save it in the persistent store.

create new object Offline -> go Online: with this fix now, once online, I can POST correctly my new object and also it gets saved into my client persistent store after receiving server success confirmation (before I was running into Serious Core Data Error as described).

create new object Offline -> close my app -> open my app and go online: In this case, as I am working on the mainQueueManagedObjectContext even force to call [mainQueueManagedObjectContext save] my object isn't saved in the persistent store.

Regarding point three it is clear to me from the documentation: "mainQueueManagedObjectContext is designed to isolate the main thread from disk I/O and avoid deadlocks. Because the primary context manages its own private queue, saving the main queue context will not result in the objects being saved to the persistent store."

but so....which is the best approach on doing a "forced" persistent store save from the mainQueueManagedObjectContext (just like RestKit does in the point 1) ?

Thanks in advance

yuwen-yan commented 9 years ago

Any updates about this issue? does RestKit support offline mode now?