Friday, 4 September 2015

ManagedObjectContext for Core Data Operations in Background thread.

- (NSManagedObjectContext*)getNewPrivateManagedObjectContext{
    NSManagedObjectContext *privateContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
    [privateContext performBlockAndWait:^{
        [privateContext setParentContext:self.managedObjectContext];
        [privateContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy];
        }];
    return privateContext ;
}
Link

No comments:

Post a Comment