Reputation: 921
I'm using NSDocument in combination with its NSUndoManager. I noticed there's a delay in setting the NSDocument updateChangeCount when pushing an undoable operation to the UndoManager:
[undoManager registerUndoWithTarget:self selector:@selector(applyUndoState:) object:state];
NSLog(@"Document.isEdited: %d", [self isDocumentEdited]);
This will show "0" if the document was not modified before this call. Seems the undomanager calls updateChangeCount later some time after this method exits. Is there a way to force the undomanager to update the document updateChangeCount ? I could manually call
if (![self isDocumentEdited])
[self updateChangeCount:NSChangeDone];
but I don't know if that would be safe in interaction with the undomanager.
Upvotes: 1
Views: 715
Reputation: 9553
NSUndoManager groups undo events automatically until the end of the current event, where it closes the current group and processes it.
I’m not sure how your would work around this because I’m not sure why you want isDocumentEdited
to change immediately.
Upvotes: 2