I’m using MagicalRecord to persist an managed object called “Me”. Here is the two methods I’m trying (the first method doesn’t persist the data but the second one does):
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
[Me MR_createInContext:localContext];
[localContext MR_save];
The above method does not persist the data but the below one does:
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
[Me MR_createInContext:localContext];
[localContext MR_saveNestedContexts];
Why is MR_save not working?
From the comments:
Refer to “Regarding MagicalRecord, what is the difference between the methods MR_saveNestedContexts and MR_save”. There is a good description between the two methods.
As of version 2.0.8, if you want to make sure you persist your nested contexts to the store, use
MR_saveNestedContexts. If you want to save up ONLY ONE parent, useMR_save. IF the parent happens to be the root/default context,MR_saveNestedContextsandMR_savedo the same thing, which is to persist to store.