How to merge changes from one child managed object context to another via a parent MOC?

前端 未结 1 517
不知归路
不知归路 2020-12-23 23:27

Hello (actual question at the bottom).

In iOS 5 there is the introduction of parent-child managed object contexts in CoreData.

I have a standard NSFetchedRes

相关标签:
1条回答
  • 2020-12-24 00:20

    According to the WWDC 2011 presentation for "What's new in Core Data" it says you should save like this:

    [child save:&error]; 
    [parent performBlock:^{
        [parent save:&parentError];
    }];
    

    From my understanding this causes the parent to receive and merge in changes from the child context. One thing to note is that the parent and all children must be created with the same concurrency type.

    -- Edit removed incorrect assumption that the parent pushes changes to the children, it does not.

    0 讨论(0)
提交回复
热议问题