what's the difference between NSManagedObjectContext reset and rollback?

拈花ヽ惹草 提交于 2019-11-30 11:03:38

The key part is in the quote

All the receiver's managed objects are “forgotten”.

- (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

-reset is different than -rollback in that it invalidates any NSManagedObjects that have been fetched from the context. Attempting to use those objects can be expected to throw an exception. However -rollback simply discards unsaved changes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!