0
votes

Am using a parent-child context syncing data with cloud kit. Am facing a problem of child overwriting the parent data. I know this is how it works but is there anything that can be done.

Below is the exact scenario.

Model

  1. Parent Entity : A
  2. Child Entity : B

A->>B is one to many relationship.

Context:

  1. Parent Context (MOC) :- Used for CRUD operation by users.

  2. Child MOC (CMOC) :- Used for syncing data from cloud kit.

Senario:

  1. A parent is deleted from child context
  2. A child for that parent is inserted on parent context.

If the save of child occurs, it overwrite the parent moc while leaving the newly inserted child without a parent.

So this leaves a child which don't have any reference parent.

1

1 Answers

0
votes

When parent is deleted from child context, it will also be deleted from the parent context when save is performed. Changes from child contexts are propagated to parent context. This is by design.

What are you trying to accomplish? There may be another way.