For testing purpose i have the following code which called from main thread (in viewDidLoad method).
for (int i = 0; i < 50; i++) {
[MagicalRecord saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
[FieldDescription MR_createEntityInContext:localContext];
// there is nothing to config, no primary attribute or smth,
// just need to create new entity and save it
} completion:^(BOOL contextDidSave, NSError * _Nullable error) {
if (!contextDidSave) {
DDLogError(@"Error saving field description: %@", error.localizedDescription);
}
}];
}
In a result, a part of entities saving is completed with contextDidSave == YES, but other part completed with contextDidSave == NO && error == nil. I get following messages in logs with it:
NO CHANGES IN ** MagicalRecord Root Saving Context ** CONTEXT - NOT SAVING
Seems like some of entities was not saved. But despite of that all entities eventually saved in storage. I can't rely on such odd result of saving operation to make my system reliable.
What i'm missing and how can i make this works without such behaviour?
p.s. I know that if i place all of 50 those calls inside saveWithBlock it will work, but my current architecture won't allow me that because i'm making a lot of MagicalRecord calls from asynchronously operations.
For testing purpose i have the following code which called from main thread (in viewDidLoad method).
In a result, a part of entities saving is completed with
contextDidSave == YES
, but other part completed withcontextDidSave == NO && error == nil
. I get following messages in logs with it:NO CHANGES IN ** MagicalRecord Root Saving Context ** CONTEXT - NOT SAVING
Seems like some of entities was not saved. But despite of that all entities eventually saved in storage. I can't rely on such odd result of saving operation to make my system reliable. What i'm missing and how can i make this works without such behaviour?p.s. I know that if i place all of 50 those calls inside saveWithBlock it will work, but my current architecture won't allow me that because i'm making a lot of MagicalRecord calls from asynchronously operations.