Note that there are some explanatory texts on larger screens.

plurals
  1. PONSManagedObjectContext - How to associate childcontext data with parentcontext data?
    primarykey
    data
    text
    <p>I'm confused on how the a child MOC (<code>NSPrivateQueueConcurrencyType</code>) works with a parent MOC (<code>NSMainQueueConcurrencyType</code>) with respect to the following scenario. I need to has a background thread check a web server for new or updated data. When something is received, I need to save or update the parent MOC. Sounds simple enough, and I see various examples. However, I'm still confused on a couple of things.</p> <p>When processing data in the background thread, I can easily save the object in the child MOC. However, in my data model, I have relationships set up as recommended. So, for example, a ConversationThread will contain an array of Messages. Each Message will have Message.parentConvoThread set in the relationship. So, whenever I'm getting new messages from the server...</p> <ol> <li>How do I associate the new Message object, which is created in the child privateMOC, with the ConversationThread (currently in the parent mainMOC)?</li> </ol> <p>Now, say that I'm getting updated personal info for the person who wrote the message. I see they have updated data on the server, so I need to update their data in app. In the privateMOC...</p> <ol> <li>How do I get the actual object (say it's MyContact) from the mainMOC to explicitly update? or... </li> <li>If I create a new MyContact in the privateMOC, how do I merge that with the currently existing MyContact in the mainMOC? ...or does it automagically happen somehow? (&lt;- I've read a lot of older threads that say you to use NSManagedObjectDidChangeNotification and manually merge but that this isn't necessary anymore...but how/why?)</li> </ol> <p>Finally, a couple of questions about searching...</p> <ol> <li>Can a search against the child privateMOC return results from the parent mainMOC (say if an entity exists in the parent but not the child)?</li> <li>If the answer to #1 is true, what happens if the entity exists in both but hasn't been merged?</li> </ol> <p>I'm quite confused on how they work together. Any help is greatly appreciated.</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