What is the Difference between Action Methods of MagicalRecord in iOS

96 views Asked by At

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.

1

There are 1 answers

2
Ashok Londhe On BEST 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.

TheandWait methods are blocking calls. The calls with completion a handler are not. These are fairly straight forward in their use.