UndoManager doesn't work with saved documents
UndoManager doesn't work with saved documents
- Subject: UndoManager doesn't work with saved documents
- From: Rob In der Maur <email@hidden>
- Date: Mon, 12 May 2003 16:59:55 +0200
I'm trying to get the undoManager to work in my document based
application but it only seems to work with new documents. As soon as I
save a document, close it, and reopen it, the undoManager doesn't work.
I check for the status of the undoManager before I register undo's
using the following code...
if ([[self undoManager] isUndoRegistrationEnabled]) NSLog(@"Undo
registration enabled...");
else NSLog(@"Undo registration not enabled...");
[[[self undoManager] prepareWithInvocationTarget:record]
setEntryName:[record entryName]];
[[[self undoManager] prepareWithInvocationTarget:record]
setNotes:[record notes]];
I thought it might be related to my loadDataRepresentation method in my
Document class, but I think that looks pretty standard...
// method to load chart data model from disk
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type
{
if (logFlag) NSLog(@"ChartDocument ->
loadDataRepresentation:ofType:...");
// check type of document
if ([type isEqualToString:RSDocumentType]) {
// tell the undo manager to suppress registration
[[self undoManager] disableUndoRegistration];
// set up the keyed unarchiver
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc]
initForReadingWith
Data:data];
// set up the chart data model using the unarchiver
[self setChart
Data:[unarchiver
decodeObjectForKey:RSDocumentChartDataModelKey]];
// tell the unarchiver we're finished
[unarchiver finishDecoding];
// release the unarchiver
[unarchiver release];
// tell the undo manager to enable registration
[[self undoManager] enableUndoRegistration];
// return success
return YES;
}
else {
if (logFlag) NSLog(@"ChartDocument ->
loadDataRepresentation:ofType: not able to unarchive...");
// return failure
return NO;
}
}
Any ideas? Am I missing something obvious here...?
Thanks.
- Rob In der Maur
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.