Core Data nested managed object contexts and frequent deadlocks / freezes

前端 未结 7 1026
囚心锁ツ
囚心锁ツ 2020-12-04 14:31

I have a problem that is almost identical to the problem described by this person here, but it hasn\'t get answered:

http://www.cocoabuilder.com/arc

相关标签:
7条回答
  • 2020-12-04 15:23

    I too got a crash related to developerSubmittedBlockToNSManagedObjectContextPerform.

    In my case, consider the following method calling pattern:

    [privatecontext performBlock:^{
        A(CDManager.privatecontext);
    }];
    

    where: A(CDManager.privateContext) calls B() B() calls C() C() calls D()

    and: method A() and method C() contains some Core Data operations. A() already have the knowledge to which context to work on, but A() doesnt inform B() about the context and so C() too doesnt have any info about on which context to work on, so C() works on default context (main). and this causes the crash due to data inconsistently in db.

    fix: all the methods which are to work on db operations are parametrized with the context they are to work on, except D() since it need not work on db operation, like:

    A(context) calls B(context) B(context) calls C(context) C(context) calls D()

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