I'm using Coredata and MagicalRecord in an iOS project, but I can't figure out some saving problems. I've one ManagedObjectContext to keep my object in memory in order to display some information. When I want to create a new entity, I create it in a background context with this following method :
__block B *b = [B MR_createInContext:[[DataBaseManager sharedManager] managedObjectContext]];
[a setB:b];
__block A *aInLocalContext;
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
B *bInLocalContext = (B *)[b MR_inContext:localContext];
aInLocalContext = (A *)[a MR_inContext:localContext];
[aInLocalContext setB: bInLocalContext];
} completion:^(BOOL success, NSError *error) {}];
b is created in my displaying context, but bInLocalContext is nil in the backgroundContext(i.e localContext), so my data is not persisted and the relationship is not set. Is it the right way to create and save new NSManagedObjectContext in a background context and keep the data in the displaying context in order to update the UI ?
Thanks in advance