Browse files

Added check to CPT code to see if store has already been added to the…

… controller. Uncommented a method to obtain permanent ids on context save
  • Loading branch information...
1 parent 8660278 commit 40b91bd93b402f77de26aa9fceca7e8ac3cb01e5 @ChronicStim committed Mar 6, 2013
View
2 MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.m
@@ -115,7 +115,7 @@ + (void) MR_setRootSavingContext:(NSManagedObjectContext *)context;
}
rootSavingContext = context;
-// [context MR_obtainPermanentIDsBeforeSaving];
+ [context MR_obtainPermanentIDsBeforeSaving];
[rootSavingContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy];
[rootSavingContext MR_setWorkingName:@"BACKGROUND SAVING (ROOT)"];
MRLog(@"Set Root Saving Context: %@", rootSavingContext);
View
11 MagicalRecord/Categories/NSPersistentStoreCoordinator+CPTDualStore.m
@@ -178,10 +178,13 @@ -(void)addCPTStores;
// Proceed with store assignment
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,[NSNumber numberWithBool:YES],NSInferMappingModelAutomaticallyOption,nil];
NSError *error = nil;
- if (![self addPersistentStoreWithType:NSSQLiteStoreType configuration:configuration URL:storeUrl options:options error:&error]) {
- DDLogError(@"Core Data Error:%@ : %@",[error localizedDescription],[error userInfo]);
- } else {
- DDLogInfo(@"Added PersistentStore at URL: %@",storeUrl);
+ // Check if a store at the url has already been assigned to the controller
+ if (![self persistentStoreForURL:storeUrl]) {
+ if (![self addPersistentStoreWithType:NSSQLiteStoreType configuration:configuration URL:storeUrl options:options error:&error]) {
+ DDLogError(@"Core Data Error:%@ : %@",[error localizedDescription],[error userInfo]);
+ } else {
+ DDLogInfo(@"Added PersistentStore at URL: %@",storeUrl);
+ }
}
}
}

0 comments on commit 40b91bd

Please sign in to comment.