views:

13

answers:

0

Hi there,

I have a little problem with NSUndoManager. When the user is about to edit some entity A, I stick everything into an undo grouping so that the changes can easily be undone. So far so good.

However, while the user is editing entity A, he can also add or edit items of entity B, where A has many B and B belongs to many A. That relationship is optional.

Now, say the user starts editing an item of entity A, called Foo. While editing, he creates a new item of entity B, called Bar. Then the user decides to cancel the whole editing process, so changes to Foo are undone, but Bar also disappears.

How do I manage to keep any changes to or additions of entity B, and only undo stuff for A?

I tried using two MOC, but because of the relationship I get errors about adding a relationship between objects of two different contexts.

Thanks!