Note that there are some explanatory texts on larger screens.

plurals
  1. POSolving CoreData error: NULL _cd_rawData but the object is not being turned into a fault
    primarykey
    data
    text
    <p>Sometimes while using Core-Data object the app crashes with the error:</p> <blockquote> <p>CoreData: error: NULL _cd_rawData but the object is not being turned into a fault</p> </blockquote> <p>From what I could research and read from the internet, is that this happens when a managed object context is passed between two threads and MOCs are not thread safe. </p> <p>This crash appears whenever I want to access a property from CD object. </p> <p>If I have Person object and want to access Perosn.name the app could crash with this error (as said before, it happens as far as I can see randomly and I cannot reproduce it, sometimes it would happen 10 times in a row and then not happen for a day or two).</p> <p>When looking at this problem, it seems that this happens when Person I get and update Person's friends relationship (this is done on the background thread, saved and merged to the main thread MOC).</p> <p>I would like to get more information about what is happening here, why does this error happen as it seems pretty randomly and if there is any way to prevent the crash.</p> <p>Below is the code where the context is saved:</p> <pre><code>__block MyAppDelegate *blockSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ [blockSelf.managedObjectContext performBlock:^{ [blockSelf.managedObjectContext save:nil]; dispatch_async(blockSelf.core_data_queue, ^{ [blockSelf.writerContext performBlock:^{ [blockSelf.writerContext save:nil]; }]; }); }]; }); </code></pre> <p><strong>Update 1</strong> Sometimes when doing the saveContext, I would get the following error:</p> <p>"Error Domain=NSCocoaErrorDomain Code=1550 "The operation couldn't be completed. (Cocoa error 1550.)</p> <p>Dangling reference to an invalid object.=null</p> <p>NSLocalizedDescription=The operation couldn't be completed. (Cocoa error 1550.), NSValidationErrorValue=Relationship 'friends' on managed object (0x201cd340)</p> <p>UID: &lt;4C1B48C8-6309-4E8E-A590-DED497907A3A>. Asset ID: (null). with objects {(\n '(null)' UID: &lt;(null)>.)}}"</p> <p>I found this answer from another SO question: "It was due to the object being set created in a different context, note not on a different thread just a different context on the same thread."</p> <p>Does this seem to be the case, and if it is how could I find where the object is created in the different context that to what I am trying to save to...</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.
 

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