Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sounds like you are creating two different Core Data stacks (<code>NSManagedObjectContext</code>, <code>NSManagedObjectModel</code>, and <code>NSPersistentStoreCoordinator</code>). What you want to do from the example is just create two <code>NSManagedObjectContext</code> instances pointing at the same <code>NSPersistentStoreCoordinator</code>. That will resolve this issue.</p> <p>Think of the <code>NSManagedObjectContext</code> as a scratch pad. You can have as many as you want and if you throw it away before saving it, the data contained within it is gone. But they all save to the same place.</p> <h2>update</h2> <p>The CoreDataBooks is unfortunately a really terrible example. However, for your issue, I would suggest <em>removing</em> the creation of the additional context and see if the error occurs. Based on the code you posted and I assume the code you copied directly from Apple's example, the double context, while virtually useless, should work fine. Therefore I suspect there is something else at play.</p> <p>Try using a single context and see if the issue persists. You may have some other interesting but subtle error that is giving you this error; perhaps a overrelease somewhere or something along those lines. But the first step is to remove the double context and see what happens.</p> <h2>update 2</h2> <p>If it is crashing even with a single MOC then your issue has nothing to do with the contexts. What is the error you are getting with a single MOC? When we solve that, then we will solve your entire issue.</p> <p>As for a better solution, use <code>NSUndoManager</code> instead. That is what it is designed for. Apple <strong>REALLY</strong> should not be recommending multiple MOCs in their example.</p> <p>I answered a question on here recently about using the <code>NSUndoManager</code> with Core Data but you can also look at some of my articles on the MDN for an example.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload