File tree Expand file tree Collapse file tree 4 files changed +26
-9
lines changed
Categories/NSManagedObjectContext Expand file tree Collapse file tree 4 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 11Pod ::Spec . new do |s |
22 s . name = 'MagicalRecord'
3- s . version = '2.0.6 '
3+ s . version = '2.0.7 '
44 s . license = 'MIT'
55 s . summary = 'Super Awesome Easy Fetching for Core Data 1!!!11!!!!1!.'
66 s . homepage = 'http://github.com/magicalpanda/MagicalRecord'
77 s . author = { 'Saul Mora' => '[email protected] ' } 8- s . source = { :git => 'https://github.com/magicalpanda/MagicalRecord.git' , :tag => '2.0.6 ' }
8+ s . source = { :git => 'https://github.com/magicalpanda/MagicalRecord.git' , :tag => '2.0.7 ' }
99 s . description = 'Handy fetching, threading and data import helpers to make Core Data a little easier to use.'
1010 s . source_files = 'MagicalRecord/**/*.{h,m}'
1111 s . framework = 'CoreData'
Original file line number Diff line number Diff line change @@ -95,13 +95,13 @@ - (void) MR_saveErrorHandler:(void (^)(NSError *))errorCallback;
9595{
9696 [self performBlockAndWait: ^{
9797 [self MR_saveWithErrorCallback: errorCallback];
98+
99+ if (self.parentContext ) {
100+ [[self parentContext ] performBlockAndWait: ^{
101+ [[self parentContext ] MR_saveErrorHandler: errorCallback];
102+ }];
103+ }
98104 }];
99-
100- if (self == [[self class ] MR_defaultContext ])
101- {
102- // Since this is a synchronous call, I made the background context save synchronous as well to reflect the intent.
103- [[[self class ] MR_rootSavingContext ] MR_saveErrorHandler: errorCallback];
104- }
105105}
106106
107107- (void ) MR_saveInBackgroundCompletion : (void (^)(void ))completion ;
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ + (void) saveWithBlock:(void (^)(NSManagedObjectContext *localContext))block com
6666
6767 if ([localContext hasChanges ])
6868 {
69- [localContext MR_saveNestedContextsErrorHandler : errorHandler];
69+ [localContext MR_saveErrorHandler : errorHandler];
7070 }
7171
7272 if (completion)
Original file line number Diff line number Diff line change @@ -65,4 +65,21 @@ - (void)testBackgroundSavesActuallySave
6565 expect ([fetchedObject hasChanges ]).to .beFalsy ();
6666}
6767
68+ - (void )testCurrentThreadSavesActuallySave
69+ {
70+ __block NSManagedObjectID *objectId;
71+ __block NSManagedObject *fetchedObject;
72+ [MagicalRecord saveWithBlock: ^(NSManagedObjectContext *localContext) {
73+ NSManagedObject *inserted = [SingleEntityWithNoRelationships MR_createInContext: localContext];
74+ expect ([inserted hasChanges ]).to .beTruthy ();
75+ [localContext obtainPermanentIDsForObjects: @[inserted] error: nil ];
76+ objectId = inserted.objectID ;
77+ }];
78+
79+ fetchedObject = [[NSManagedObjectContext MR_rootSavingContext ] objectWithID: objectId];
80+
81+ expect (fetchedObject).toNot .beNil ();
82+ expect ([fetchedObject hasChanges ]).to .beFalsy ();
83+ }
84+
6885@end
You can’t perform that action at this time.
0 commit comments