Hi, I am trying to understand how to access the data imported by
+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData;
in my TableViewControllers / FetchedResultControllers.
In my app, I do not use threading. The only setup I do is
Then I use the method above to import a JSON object for my entity named "User". My problem is currently that my data doesn't seem to get persisted (or it maybe does in some other context I am not aware of), because after the import is done, and I exit and relaunch the app, then dump the records using:
NSNumber *count = [User MR_numberOfEntities];
The count is zero (0). When I dump the records right after the fetch, the count is 1 (correct). Out of curiosity, right after the import, I tried:
[[NSManagedObjectContext MR_defaultContext] MR_saveNestedContexts];
and then the data was there even after I exited and relaunched the app. But this is confusing to me - why do I need to save twice? I would rather like to be able to write my app without thinking about multiple contexts (so I don't have to use the "inContext" variants of the MR library).
I understand that importFromArray saves into the context created at setup by
So I was wondering what the best practice is to fetch JSON, import it into CoreData, and immediately be able to read from it in my FRC or other controllers, and, most importantly, have it persisted between app launches.