Please explain the Difference between below mentioned methods.
- (void)save:
- (void)saveOnlySelfAndWait;
- (void)saveToPersistentStoreAndWait;
Note: Some one have posted answer of this question but i am not satisfied with that answer so can anyone please share proper and simple answer.
After thinking and searching lot i got answer ...
I acknowledge that these methods aren't documented very well. However, they follow with the Core Data nested context model fairly well.
With MagicalRecord don't use
save:
on anNSManagedObjectContext
. MagicalRecord has all those extra error handling, logging and completion handlers built in. You want to use those.You seem to know where data needs to go (from one context to the root). It depends on your hierarchy as to which save method you need to use. If you are only one level deep (ie. in a child context of the defaultContext),
saveOnlySelfAndWait
will save to thedefaultContext
. Otherwise,saveToPersistentStoreAndWait
will traverse the hierarchy for you, all the way to the data store.The
andWait
methods are blocking calls. The calls with completion a handler are not. These are fairly straight forward in their use.