开发者

Nested undo with NSUndoManager and Core Data

I have a littl开发者_如何学JAVAe 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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜