撤消在视图控制器中所做的所有更改 [英] undo all changes made in a view controller

查看:104
本文介绍了撤消在视图控制器中所做的所有更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以撤消在视图控制器中所做的所有更改而不会影响在其父视图控制器中所做的更改?顺便提一句.它们具有相同的managedObjectContext. ps.我有两个实体A和B.A与B有很多关系.视图控制器VCA用于在A中执行某些更改.视图控制器VCB用于在B中执行某些更改.VCA是VCB的父视图控制器.

Is it possible to undo all changes made in a view controller without affecting the changes made in its parent view controller? btw. They are with the same managedObjectContext. ps. I have two entities A and B. A has an to-many relationships to B. View controller VCA is used to perform some changes in A. View controller VCB is used to perform some changes in B. VCA is the parent view controller of VCB.

推荐答案

无需创建新的上下文.离开子视图控制器时,您可以选择以下任一选项:

No need to create a new context. When you leave the child view controller, you have the option of either

[managedObjectContext save:&error];

[managedObjectContext rollback];

在后一种情况下,所有新实体实例,数据修改等将被丢弃.

In the latter case, all your new entity instances, data modifications etc. will be discarded.

这篇关于撤消在视图控制器中所做的所有更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆