Skip to content

Loading…

Obtain permanent IDs on inserted objects before saving #250

Merged
merged 1 commit into from

1 participant

@blackgold9
Magical Panda Software member

This will fix many cases of object relationships being busted, strange crashes, and much bad behavior

@blackgold9 blackgold9 merged commit dffde9f into magicalpanda:iOS5NestedContextFix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2 MagicalRecord/Core/MagicalRecordNestedContextsPersistenceStrategy.m
@@ -17,6 +17,8 @@ - (void)setUpContextsWithCoordinator:(NSPersistentStoreCoordinator *)coordinator
NSManagedObjectContext *defaultContext = [NSManagedObjectContext MR_newMainQueueContext];
[defaultContext setParentContext:rootContext];
[NSManagedObjectContext MR_setDefaultContext:defaultContext];
+ [NSManagedObjectContext MR_makeContextObtainPermanentIDsBeforeSaving:defaultContext];
+ [NSManagedObjectContext MR_makeContextObtainPermanentIDsBeforeSaving:rootContext];
[NSManagedObjectContext MR_makeContext:rootContext mergeChangesToContext:defaultContext];
}
View
3 MagicalRecord/Core/MagicalRecordParallelStoresPersistenceStrategy.m
@@ -33,7 +33,8 @@ - (void)setUpContextsWithCoordinator:(NSPersistentStoreCoordinator *)coordinator
// Use the coordinator passed in
[defaultContext setPersistentStoreCoordinator:coordinator];
[NSManagedObjectContext MR_setDefaultContext:defaultContext];
-
+ [NSManagedObjectContext MR_makeContextObtainPermanentIDsBeforeSaving:defaultContext];
+ [NSManagedObjectContext MR_makeContextObtainPermanentIDsBeforeSaving:rootContext];
[NSManagedObjectContext MR_makeContext:rootContext mergeChangesToContext:defaultContext];
[NSManagedObjectContext MR_makeContext:defaultContext mergeChangesToContext:rootContext];
}
Something went wrong with that request. Please try again.