• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UndoManager doesn't work with saved documents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UndoManager doesn't work with saved documents


  • Subject: Re: UndoManager doesn't work with saved documents
  • From: Rob In der Maur <email@hidden>
  • Date: Tue, 13 May 2003 15:57:21 +0200

Wolfgang,

Thanks, but I sorted it out; I forgot to associate my data model after loading it with the file content with the document itself, using:

// init the model after we unarchived
[[self chartData] initAfterUnarchivingWithDocument:self];


The initAfterUnarchivingWithDocument method in my model class actually is very simple and looks like

- (void)initAfterUnarchivingWithDocument:(ChartDocument *)inDocument
{
document = inDocument;
}


That did the trick. Got it from Cheeseman's excellent book 'Cocoa Recipes'....

Thanks,
Rob

On Tuesday, May 13, 2003, at 15:31 Europe/Amsterdam, Wolfgang Ante wrote:

The only thing that I do differently in my 'loadDataRepresentation:' is...

[undoManager removeAllActions];

...instead of your 'disableUndoRegistration' and 'enableUndoRegistration'.

Bye, Wolfgang :-)

--
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]
initForReadingWithData:data];
// set up the chart data model using the unarchiver
[self setChartData:[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.




- 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.

  • Follow-Ups:
    • Re: UndoManager doesn't work with saved documents
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: KeyCode <=> ASCII problem...
  • Next by Date: Re: Design question
  • Previous by thread: UndoManager doesn't work with saved documents
  • Next by thread: Re: UndoManager doesn't work with saved documents
  • Index(es):
    • Date
    • Thread