0

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.

4

1 回答 1

0

经过思考和搜索后,我得到了答案......

我承认这些方法没有很好地记录。但是,它们很好地遵循了 Core Data 嵌套上下文模型。

使用 MagicalRecord 不要save:NSManagedObjectContext. MagicalRecord 内置了所有这些额外的错误处理、日志记录和完成处理程序。你想使用它们。

您似乎知道数据需要去哪里(从一个上下文到根)。这取决于您需要使用哪种保存方法的层次结构。如果您只有一层深度(即在 defaultContext 的子上下文中),saveOnlySelfAndWait将保存到defaultContext. 否则,saveToPersistentStoreAndWait将为您遍历层次结构,一直到数据存储。

这些andWait方法是阻塞调用。处理程序完成的调用不是。这些在使用中是相当直接的。

于 2015-06-12T11:52:02.367 回答