2

NSUndoManager groups invocations together that happen in the same runloop.

I want to load a document that contains the undo history within it.

As such, I create a document and apply the invocations one-by-one, these however all get added very quickly, resulting in a single undo.

Is there a way I can change the NSUndoManagers runloop or something else so that I get separate undo invocations?

I have tried disabling groupsByEvent and creating my own beginUndoGrouping but it doesn't seem to work

Chris
  • 2,739
  • 4
  • 29
  • 57
  • It seems that I need to wrap a beginUndoGrouping() and endUndoGrouping() around all of my "add" operations, I'm not sure If I feel this is correct behaviour though. My thinking is that a top level beginUndoGrouping should affect all subsequent "adds" to the undo manager... – Chris Jan 05 '15 at 22:11

1 Answers1

1

Have you tried closing the toplevel group and opening it again after you added your invocations? E.g.:

undoManager.endUndoGrouping()

// add your undo invocations

undoManager.beginUndoGrouping()
lassej
  • 6,256
  • 6
  • 26
  • 34