Skip to content

Commit

Permalink
fixed some Issues with Parent-Child-Contexts and ConcurrencyTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
messi committed Mar 5, 2013
1 parent 0ea8944 commit 846c2ab
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions NSManagedObjectContext+PSCCoreDataHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ - (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSUInteger)concu
}

- (NSManagedObjectContext *)newChildContext {
return [self newChildContextWithConcurrencyType:NSConfinementConcurrencyType];
return [self newChildContextWithConcurrencyType:NSPrivateQueueConcurrencyType];
}

- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)error {
if (self.hasChanges) {
[self performBlockAndWait:^{
if (self.concurrencyType == NSConfinementConcurrencyType) {
[self save:error];
}];
} else {
[self performBlockAndWait:^{
[self save:error];
}];
}
}

if (error != nil || self.parentContext == nil) {
if (*error != nil || self.parentContext == nil) {
return;
}

Expand All @@ -36,7 +40,9 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)err
};

if (self.parentContext.hasChanges) {
if (wait) {
if (self.parentContext.concurrencyType == NSConfinementConcurrencyType) {
saveParent();
} else if (wait) {
[self.parentContext performBlockAndWait:saveParent];
} else {
[self.parentContext performBlock:saveParent];
Expand Down

0 comments on commit 846c2ab

Please sign in to comment.