It seems I tried everything but it seems it works in main thread only. For example:
[SomeClass MR_createEntity];
[[NSManagedObjectContext MR_defaultContext] MR_saveWithOptions:MRSaveSynchronously completion:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"You successfully saved your context.");
} else if (error) {
NSLog(@"Error saving context: %@", error.description);
}
}];
If this code is run in main thread then success == YES
otherwise (in background thread) it gives success == NO
. In both cases error == nil
.
So is it impossible to call the saving in background thread?
Finally I hadn't to create a workable project with fully background MagicalRecord work.
The best solution for me is to update database in the main thread only and to read the database in any thread (including background). Additionally I show custom progress view on database updating.