NSManagedObjectContext async import, save and notify main context

I have got parent child context as follow:
1. writercontext with NSPrivateQueueConcurrencyType
2. mainContext with NSMainQueueConcurrencyType ParentContext:writercontext
3. and background context with NSPrivateQueueConcurrencyType ParentContext:writercontext

how can i notify the main context with changes made by background context?

i have read the last part: async save but that doesnt save or import in the background and it gets the UI blocked and unresponsive. is there a way with child parent context in backgound and still notify main context?

currently i save my context:

[context performBlockAndWait:^{
    @try {
        NSError *childError = nil;
        if ([context save:&childError])
        {
            [context.parentContext performBlockAndWait:^{
                NSError *parentError = nil;
                if ([context.parentContext save:&parentError])
                {
                     //saved
                }
                else
                {
                    nslog(@"Error: %@", parentError.description);
                }
            }];
        }
        else
        {
            DBERROR(@"Error: %@", childError.description);
        }
    }
    @catch (NSException *exception)
    {
        DBERROR(@"Exception: %@", exception.description);
    }

}];

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>