Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had this same issue, this is what I figured out, and how I resolved it.</p> <p>Magical Record has a root <code>NSManagedObjectContext</code> as a parent of the default <code>NSManagedObjectContext</code>. When I create an <code>NSFetchedResultsController</code> in the default context, everything seems to work fine, just like you. </p> <p>The problem is that all the <em>new</em> <code>NSManagedObject</code>'s come back with their still-temporary <code>ObjectID</code>'s. So, in my case, I was using an <code>NSPredicate</code> to scope a query on an associated table. I didn't just call the association method because I didn't want to load <em>everything</em> into memory and wanted <code>NSFetchedResultsController</code> to handle changes, for me. </p> <p>With the temporary <code>ObjectID</code> the query finds zero results and that's exactly what it displays.</p> <p>Apparently the child context (default) doesn't get the benefit of the transformation to non-temporary ID's, even though it's been persisted to the backing store.</p> <p>Even worse badness happened when I tried to force the issue with <code>obtainPermanentIDsForObjects:error:</code>. Core Data complained that it could not satisfy a fault for my instance. Nevermind, there's no way it was actually a fault. Simply refreshing the object had no effect, either. I suspect this is a Core Data bug that hardly no one tickles because they just use the association methods to get an NSSet.</p> <p>My fix was to use the parent context for the <code>NSFetchedResultsController</code>, just like in this question, <a href="https://stackoverflow.com/questions/10974713/magical-record-saving-and-nsfetchedresultscontroller">Magical Record, saving, and NSFetchedResultsController</a>.</p> <p>I was already wrapping the default in a new child context upon edit and, therefore, copying the instances into that editing context with <code>createInContext</code>, so I didn't have to do any extra work beyond just adding <code>.parentContext</code> to the argument.</p> <p>Incidentally, this only ever happened on new instances of the source of the association. Once an instance was there from startup, it had a non-temporary <code>ObjectID</code> and never had the issue.</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