سؤال

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];

or

[managedObjectContext rollback];

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

نصائح أخرى

You should create new NSManagedObjectContext for child view controller and attach undo to it. NSManagedObjectContext is very light and doesn't cost very much.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top