What's the appropriate way of using MagicalRecord for importing data in the background and accessing the just imported data on completion? Do I have to manually save the primary keys of all imported data and pass that to the completion block in order to find them again from CoreData?
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext)
{
NSArray *importedEntitiesArray = [MyEntity MR_importFromArray:bigResultsArray
inContext:localContext];
} completion:^(BOOL success, NSError *error)
{
// How to access the imported entities from here?
// Note we no longer have access to the saving localContext
// so the entities in importedEntitiesArray would be invalid
}]
I realize I can do the following:
NSArray *importedEntitiesArray = [MyEntity MR_importFromArray:bigResultsArray];
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];
But that doesn't import the data in the background.