• 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
CoreData based document NSUndoManager troubles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData based document NSUndoManager troubles


  • Subject: CoreData based document NSUndoManager troubles
  • From: Colin Cornaby <email@hidden>
  • Date: Tue, 16 Aug 2005 22:45:03 -0700

At init time for my NSPersistentDocument I clear the undo stack after I do setup. This works fine. The stack is cleared and the document appears as not modified. The code I use is:


[[self managedObjectContext] processPendingChanges]; [[[self managedObjectContext] undoManager] removeAllActions]; [self updateChangeCount:NSChangeCleared];

I then use the following code within an NSManagedObject subclass when it is modified:

[[[self managedObjectContext] undoManager] registerUndoWithTarget:self
selector:@selector(setResourceData:)
object:[self valueForKey:@"data"]];
[[[self managedObjectContext] undoManager] setActionName:@"Edit Resource"];


However, this code doesn't enable the undo menu item. I did read that I may need to do an updateChangeCount on the NSDocument, but this raises a few issues. First, I thought if I was using the NSDocument's undoManager (which is shared by the managedObjectContext) that I wouldn't need to use updateChangeCount. Secondly, the CoreData code shouldn't really be talking to something as higher than it as the NSPersistentDocument. Have I done something wrong? Is there any way I can get this working without having my schema classes talk to the NSDocument classes?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: CoreData based document NSUndoManager troubles
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Model Tool
  • Next by Date: Setting view contents...
  • Previous by thread: Model Tool
  • Next by thread: Re: CoreData based document NSUndoManager troubles
  • Index(es):
    • Date
    • Thread