问题描述
文件说明:
看来我对我的上下文做了一些改变后,调用这两个方法将做同样的事情:discard changes并将更新的对象恢复到其上次提交的值。那么 -reset
实际上是做什么的?
- (void)reset;
会给你一个干净的 NSManagedObjectContext
它和文档状态任何 NSManagedObject
'你应该被丢弃,因为他们不再有效。
- (void)rollback
将只是将 NSManagedObject
恢复为它们的持久值
The documentation says:
It seems that after I make some change to my context, calling these two method will do exactly the same thing: discard changes and restore updated objects to their last committed values. So what does -reset
actually do?
The key part is in the quote
- (void)reset;
will give you a clean NSManagedObjectContext
with no objects in it and as the docs state any NSManagedObject
's you have around should be discarded as they are no longer valid.
- (void)rollback
will just restore the NSManagedObject
's to their persisted values
这篇关于NSManagedObjectContext重置和回滚之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!