jeudi 31 mars 2016

Core Data: SQLite not being updated immediately

There are two Entities- Document and Page. Document has a one-to-many relationship with Page.

I save the managed object context when I add document. At this point, there are no pages in them. While debugging I found that the writer context's save method does get called and is executed without error. I close and reopen the app and I can't find the previously saved Document objects. But, if I add a page in one of the document, then, the Document object appear in the table. I use a tool to view the SQLite file but my observation is not based on what I see in the tool. Even when I debug and see the number of documents present, I get 0 back when there is no page in them.

I am guessing that the Persistent Store Coordinator is doing some kind of optimization to write in batch. Can I force it to write and update the persistent store immediately? Is there a option that I can add while calling addPersistentStoreWithType on the persistent store object?

Note: Just FYI, I use this pattern to organize the Managed Object Context(s)

Aucun commentaire:

Enregistrer un commentaire