Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on your question and your comments, you are:</p> <ul> <li>Using a single managed object on multiple threads.</li> <li>Not taking any precautions to deal with the fact that <code>NSManagedObjectContext</code> is not thread safe.</li> </ul> <p>As a result, you are getting weird, confusing crashes.</p> <p>This is exactly what one would expect in this situation. Using a managed object context on more than one thread without taking precautions is essentially a recipe for crashes and confusion. These crashes may not make a lot of sense, because you're corrupting the context's internal state.</p> <p>If you want to use a context on more than one thread, you <em>must</em> use one of the queue confinement options (<code>NSMainQueueConcurrencyType</code> or <code>NSPrivateQueueConcurrencyType</code>) and then you <em>must</em> put all code that uses the context or any object fetched from them in a <code>performBlock:</code> or <code>performBlockAndWait:</code>. (Exception: if you use <code>NSMainQueueConcurrencyType</code> and you know your code is on the main thread, you may just use the context directly). You might also use your own locking mechanism via something like <code>NSLock</code>, but come on, threading is already hard enough for most people.</p> <p>It's generally better to use one context per thread, either as parent/child contexts or as independent contexts, but the approach above also works.</p> <p>If you've actually managed to save bogus objects as a result of this, the only real recourse is to fetch those objects and either fix them up or delete them. How to identify these objects depends on your data model-- there's no universal test for "is this object crap?". Any checks depend on what your app considers to be correct.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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