Undoing edits


#1

When observing value changes, we put this on the undo stack:

Couldn’t we just as well put:


#2

Interesting question, I just tried it and got an exception:

2012-01-03 22:56:49.024 RaiseMan[1086:707] An uncaught exception was raised 2012-01-03 22:56:49.024 RaiseMan[1086:707] [<RMDocument 0x10041ecf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key personName.
I made some inquiries, and found, that the problem is, that NSUndoManager knows the message setValue:forKeyPath: so it will not call forwardInvocation: (only called for unknown messages) to forward the message to the target object (RMDocument). Also look at page 145 or the Apple Docu here.

It wasn’t easy to figure out :wink:

cu
Vertex


#3

I get the correct behavior when using setValue:forKeyPath: directly. Vertex, did you change the argument to prepareInvocationWithTarget: to object (from self)?

The reason for this indirection is that there was a bug in NSUndoManager, as Vertex points out, where it would fail to capture calls to setValue:forKey:. Based on my testing, however, this bug appears to have been fixed.

Adam


#4

I am sorry for the confusion,I did make a mistake yesterday.

Exactly Adam, that was my fault :blush: I have just tried it again and it worked smoothly

cu
Vertex